(empty-record this)
Same a c.c/empty, but work on records. An empty record is a record with all
fields initialized to nil
Same a c.c/empty, but work on records. An empty record is a record with all fields initialized to `nil`
(generate-strict-where-from-entity entity)
Generate a where clause from entity, preserving nils value for primary-keys.
Generate a where clause from entity, preserving nils value for primary-keys.
(generate-where-from-entity entity)
Generate a where clause from an entity, ignore nil values for primary keys.
Generate a where clause from an entity, ignore nil values for primary keys.
(generated-pk rs-item)
Return the generated primary key of resultset item
Return the generated primary key of resultset item
(invoke-record-constructor this amap)
For a record instance, invoke the auto-generated map->Record factory function.
For a record instance, invoke the auto-generated map->Record factory function.
(recover-entities db entity resultset)
Take a db-spec, entity, a resultset and will re-fetch all resultset items from db. If no primary key are available, return the resultset.
Take a db-spec, entity, a resultset and will re-fetch all resultset items from db. If no primary key are available, return the resultset.
(save! db entity & {:keys [opts]})
Save a map or a coll of maps in the given table, only save keys matching existing columns.
Save a map or a coll of maps in the given table, only save keys matching existing columns.
(save-subentities! db entity subentities relation-key getterf)
Upsert and/or delete the designated subentities
in db
, implementing the
save operation on a one-to-many relationship. Take a db
spec, an entity
, a
key designating a slot of related subentities
, a relation-key
keyword
naming the reference from the subentity to the entity, and a 2 arity getterf
function. Will use getterf
, passing it db
and entity
to find the actual
subentities in db
, diff them agains the given subentities
and perform 2
actions in this order: save in db
all given subentities
setting their
relation-key
to the entity's primary-key, then delete from db
the ones
present in db
but not in subentities
.
Example: (save-subentities! db user :posts :user-id posts/find-by-user)
Upsert and/or delete the designated `subentities` in `db`, implementing the save operation on a one-to-many relationship. Take a `db` spec, an `entity`, a key designating a slot of related `subentities`, a `relation-key` keyword naming the reference from the subentity to the entity, and a 2 arity `getterf` function. Will use `getterf`, passing it `db` and `entity` to find the actual subentities in `db`, diff them agains the given `subentities` and perform 2 actions in this order: save in `db` all given `subentities` setting their `relation-key` to the entity's primary-key, then delete from `db` the ones present in `db` but not in `subentities`. Example: (save-subentities! db user :posts :user-id posts/find-by-user)
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close