Back

get-by-id (clj)

(source)

function

(get-by-id connectable table pk) (get-by-id connectable table pk opts) (get-by-id connectable table pk pk-name opts)
Syntactic sugar over `execute-one!` to make certain common queries easier. Given a connectable object, a table name, and a primary key value, returns a hash map of the first row that matches. By default, the primary key is assumed to be `id` but that can be overridden in the five-argument call. As with `find-by-keys`, you can specify `:columns` to return just a subset of the columns in the returned row. Technically, this also supports `:order-by`, `:top`, `:limit`, `:offset`, and `:fetch` -- like `find-by-keys` -- but they don't make as much sense here since only one row is ever returned.

Examples