Liking cljdoc? Tell your friends :D

toucan2.model


default-connectableclj

(default-connectable model)

The default connectable that should be used when executing queries for model if no toucan2.connection/*current-connectable* is currently bound. By default, this just returns the global default connectable, :default, but you can tell Toucan to use a different default connectable for a model by implementing this method.

The default connectable that should be used when executing queries for `model` if
no [[toucan2.connection/*current-connectable*]] is currently bound. By default, this just returns the global default
connectable, `:default`, but you can tell Toucan to use a different default connectable for a model by implementing
this method.
sourceraw docstring

deferred-current-connectableclj

(deferred-current-connectable model)
source

do-with-modelclj

(do-with-model modelable f)
source

primary-key-valuesclj

(primary-key-values instance)
(primary-key-values model m)

Return a map of primary key values for a Toucan 2 instance.

Return a map of primary key values for a Toucan 2 `instance`.
sourceraw docstring

primary-keysclj

(primary-keys model)

Return a sequence of the primary key columns names, as keywords, for a model. The default primary keys for a model are [:id]; implement this method if your model has different primary keys.

;; tell Toucan that :model/bird has a composite primary key consisting of the columns :id and :name
(m/defmethod primary-keys :model/bird
  [_model]
  [:id :name])

If an implementation returns a single keyword, the default :around method will automatically wrap it in a vector. It also validates that the ultimate result is a sequence of keywords, so it is safe to assume that calls to this will always return a sequence of keywords.

Return a sequence of the primary key columns names, as keywords, for a model. The default primary keys for a model are
`[:id]`; implement this method if your model has different primary keys.

```clj
;; tell Toucan that :model/bird has a composite primary key consisting of the columns :id and :name
(m/defmethod primary-keys :model/bird
  [_model]
  [:id :name])
```

If an implementation returns a single keyword, the default `:around` method will automatically wrap it in a vector. It
also validates that the ultimate result is a sequence of keywords, so it is safe to assume that calls to this will
always return a sequence of keywords.
sourceraw docstring

select-pks-fnclj

(select-pks-fn modelable)

Return a function to get the value(s) of the primary key(s) from a row, as a single value or vector of values. Used by toucan2.select/select-pks-reducible and thus by toucan2.select/select-pks-set, toucan2.select/select-pks-vec, etc.

The primary keys are determined by primary-keys. By default this is simply the keyword :id.

Return a function to get the value(s) of the primary key(s) from a row, as a single value or vector of values. Used
by [[toucan2.select/select-pks-reducible]] and thus
by [[toucan2.select/select-pks-set]], [[toucan2.select/select-pks-vec]], etc.

The primary keys are determined by [[primary-keys]]. By default this is simply the keyword `:id`.
sourceraw docstring

table-nameclj

(table-name model)
source

with-modelcljmacro

(with-model [model-binding modelable] & body)
source

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

× close