Liking cljdoc? Tell your friends :D

pg.honey

HoneySQL wrappers and shortcuts.

HoneySQL wrappers and shortcuts.
raw docstring

deleteclj

(delete src table)
(delete src table {:as opt :keys [where returning] :or {returning [:*]}})
source

executeclj

(execute src sql-map)
(execute src sql-map {:as opt :keys [honey]})

Like pg.core/execute but accepts a HoneySQL map which gets rendered into SQL vector and split on a query and parameters.

Arguments:

  • conn: a connectable source;
  • sql-map: a map like {:select [:this :that] :from [...]}
  • opt: PG2 options; pass the :honey key for HoneySQL params.

Result:

  • same as pg.core/execute.
Like `pg.core/execute` but accepts a HoneySQL map
which gets rendered into SQL vector and split on a query
and parameters.

Arguments:
- conn: a connectable source;
- sql-map: a map like {:select [:this :that] :from [...]}
- opt: PG2 options; pass the `:honey` key for HoneySQL params.

Result:
- same as `pg.core/execute`.
sourceraw docstring

findclj

(find src table)
(find src table kv)
(find src
      table
      kv
      {:as opt :keys [fields limit offset order-by] :or {fields [:*]}})

Select rows by a column->value filter, for example:

{:name 'Foo', :active true}

All the kv pairs get concatenated with AND.

The optional arguments are:

  • fields (default is [:*])
  • limit
  • offset
  • order-by
Select rows by a column->value filter, for example:

{:name 'Foo', :active true}

All the kv pairs get concatenated with AND.

The optional arguments are:
- fields (default is [:*])
- limit
- offset
- order-by
sourceraw docstring

find-firstclj

(find-first src table kv)
(find-first src
            table
            kv
            {:as opt :keys [fields offset order-by] :or {fields [:*]}})

Like find but gets the first row only. Adds the limit 1 expression to the query. Supports the same optional arguments.

Like `find` but gets the first row only. Adds the
limit 1 expression to the query. Supports the same
optional arguments.
sourceraw docstring

formatclj

(format sql-map)
(format sql-map opt)

Like honey.sql/format but with some Postgres-related overrides. Namely, it produces a SQL expressions with dollar signs instead of question marks, e.g. SELECT * FROM USERS WHERE id = $1.

Like honey.sql/format but with some Postgres-related overrides.
Namely, it produces a SQL expressions with dollar signs instead
of question marks, e.g. `SELECT * FROM USERS WHERE id = $1`.
sourceraw docstring

get-by-idclj

(get-by-id src table id)
(get-by-id src table id {:as opt :keys [pk fields] :or {pk :id fields [:*]}})

Get a single row by its primary key.

By default, the name of the primary key is :id which can be overridden by the :pk parameter.

The optimal :fields vector specifies which columns to return, [:*] by default.

Get a single row by its primary key.

By default, the name of the primary key is `:id`
which can be overridden by the `:pk` parameter.

The optimal `:fields` vector specifies which
columns to return, `[:*]` by default.
sourceraw docstring

get-by-idsclj

(get-by-ids src table ids)
(get-by-ids src
            table
            ids
            {:as opt :keys [pk fields order-by] :or {pk :id fields [:*]}})

Get multiple rows from a table by their PKs. It's not recommended to pass thousands of PKs at once. Split them by smaller chunks instead.

Like get-by-id, accepts the PK name, the column names to return, and order-by clause.

Returns a vector of rows.

Get multiple rows from a table by their PKs. It's not
recommended to pass thousands of PKs at once. Split
them by smaller chunks instead.

Like `get-by-id`, accepts the PK name, the column names
to return, and order-by clause.

Returns a vector of rows.
sourceraw docstring

HONEY_OVERRIDESclj

source

insertclj

(insert src table kvs)
(insert src
        table
        kvs
        {:as opt
         :keys [returning on-conflict do-update-set do-nothing]
         :or {returning [:*]}})

Insert a collection of rows into a table. The kvs argument must be a seq of maps.

The optional arguments are:

  • returning: a vector of columns to return, default is [:*]
  • on-conflict,
  • do-update-set,
  • do-nothing: Postgres-specific ON CONFLICT ... DO ... expressions.

Other PG2-related options are supported.

The result depends on the returning clause and PG2 options. By default, it will be a vector of inserted rows.

Insert a collection of rows into a table.
The `kvs` argument must be a seq of maps.

The optional arguments are:
- returning: a vector of columns to return, default is [:*]
- on-conflict,
- do-update-set,
- do-nothing: Postgres-specific ON CONFLICT ... DO ... expressions.

Other PG2-related options are supported.

The result depends on the `returning` clause and PG2 options.
By default, it will be a vector of inserted rows.
sourceraw docstring

insert-oneclj

(insert-one src table kv)
(insert-one src
            table
            kv
            {:as opt
             :keys [returning on-conflict do-update-set do-nothing]
             :or {returning [:*]}})

Like insert but accepts a single row.

Supports the same options. The default result is a single inserted row.

Like `insert` but accepts a single row.

Supports the same options. The default result
is a single inserted row.
sourceraw docstring

prepareclj

(prepare src sql-map)
(prepare src sql-map {:as opt :keys [honey]})

Prepare a statement expressed wit a Honey map. For parameters, use either blank values or raw expressions, for example:

{:select [:*] :from :users :where [:= :id 0]}

or

{:select [:*] :from :users :where [:raw 'id = $1']}

Return an instance of PreparedStatement class.

Prepare a statement expressed wit a Honey map.
For parameters, use either blank values or raw
expressions, for example:

{:select [:*] :from :users :where [:= :id 0]}

or

{:select [:*] :from :users :where [:raw 'id = $1']}

Return an instance of `PreparedStatement` class.
sourceraw docstring

queriesclj

(queries src sql-maps)
(queries src sql-maps {:as opt :keys [honey]})

Like query but accepts a vector of SQL maps. Returns a vector of results.

Like `query` but accepts a vector of SQL maps.
Returns a vector of results.
sourceraw docstring

queryclj

(query src sql-map)
(query src sql-map {:as opt :keys [honey]})

Like pg.core/query but accepts a HoneySQL map which gets rendered into a SQL string.

Arguments:

  • src: a connectable source;
  • sql-map: a map like {:select [:this :that] :from [...]}
  • opt: PG2 options; pass the :honey key for HoneySQL params.

Result:

  • the same as pg.core/query.
Like `pg.core/query` but accepts a HoneySQL map
which gets rendered into a SQL string.

Arguments:
- src: a connectable source;
- sql-map: a map like {:select [:this :that] :from [...]}
- opt: PG2 options; pass the `:honey` key for HoneySQL params.

Result:
- the same as `pg.core/query`.
sourceraw docstring

updateclj

(update src table kv)
(update src table kv {:as opt :keys [where returning] :or {returning [:*]}})

Update rows in a table. The kv is a map of field->value. Note that the value might be not a scalar but something like [:raw 'now()'] or any other HoneySQL expression.

The optional parametes are:

  • where which acts like a filter when updating the rows;
  • returning which determines what columns to return.
Update rows in a table. The `kv` is a map of field->value.
Note that the value might be not a scalar but something
like `[:raw 'now()']` or any other HoneySQL expression.

The optional parametes are:
- `where` which acts like a filter when updating the rows;
- `returning` which determines what columns to return.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close