Back

select-one! (clj)

(source)

function

(select-one! connectable cols sql-params) (select-one! connectable cols sql-params opts)
Execute the SQL and params using `next.jdbc/plan` and return just the selected columns from just the first row. `(plan/select-one! ds [:total] ["select count(*) as total from table"])` ;;=> {:total 42} If the `cols` argument is a vector of columns to select, then it is applied using `select-keys`, otherwise, the `cols` argument is used as a function directly. That means it can be a simple keyword to return just that column -- which is the most common expected usage: `(plan/select-one! ds :total ["select count(*) as total from table"])` ;;=> 42 The usual caveats apply about operations on a raw result set that can be done without realizing the whole row.

Examples