(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.
(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`.
(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.
(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`.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close