Liking cljdoc? Tell your friends :D

Rendering

Rendering is the process of turning:

  • a SQL template
  • a params map

into:

  • rendered SQL
  • bind params
  • metadata

Render Result Shape

Rendering returns a map like this:

{:sql "SELECT * FROM users WHERE id = ?"
 :params [42]
 :meta {}}

If declaration comments exist, :meta contains them.

Bind Variables

WHERE id = /*$id*/1
{:id 42}

{:sql "WHERE id = ?"
 :params [42]}

Collection Binding

WHERE id IN /*$ids*/(1,2,3)
{:ids [10 20 30]}

{:sql "WHERE id IN (?, ?, ?)"
 :params [10 20 30]}

Conditional Rendering

WHERE
/*%if active */
  active = true
/*%else => status = 'inactive' */
/*%end */

The rendered SQL depends on the truthiness of active.

DEFAULT and ALL

bisql/DEFAULT and bisql/ALL are rendered as SQL keywords for scalar $ bindings.

{:status bisql/DEFAULT
 :limit bisql/ALL}

Runtime APIs

Typical user-facing APIs are:

  • bisql.core/defrender
  • bisql.core/defquery

For lower-level examples, see:

Can you improve this documentation?Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close