(?->> pred? expr & forms)
(?->> &form &env pred? expr & forms)
Like clojure.core/some->>
but short-circuit when the value do not satisfy the
predicate pred?
. (?->> nil? ...) is equivalent to clojure.core/some->>
.
Like `clojure.core/some->>` but short-circuit when the value do not satisfy the predicate `pred?`. (?->> nil? ...) is equivalent to `clojure.core/some->>`.
(attach-lifecycle entity-name {:keys [on-fetch on-save on-delete]})
(defentity entity-name {:keys [primary-key id-type store]})
(fetch! this db)
(fetch! this db where-clause)
(fetch! this db where-clause opts)
(primary-key this)
Return the primary key
Return the primary key
(identity this)
Return the primary key's value
Return the primary key's value
(init this)
Act as constructor. Given a basis record (built with
constructor functions or static constructor) will set the primary key to a
newly generated id. If the entity has no specific instrution on how to
generate an id, will leave it nil for the database to apply it's DEFAULT. If
entitie's primary key is composite (tuple of ids) you need to either overload
the default implementation and set them by yourself. If the record already
have an id and you want to preserve it, then use bf.crud.core/save!
instead.
Act as constructor. Given a basis record (built with constructor functions or static constructor) will set the primary key to a newly generated id. If the entity has no specific instrution on how to generate an id, will leave it nil for the database to apply it's DEFAULT. If entitie's primary key is composite (tuple of ids) you need to either overload the default implementation and set them by yourself. If the record already have an id and you want to preserve it, then use `bf.crud.core/save!` instead.
(join entities subentities slot join-key)
(join entities subentities slot join-key one-to-one-join?)
Take a list of entities
that can be Identified, and a list of arbitrary
subentities
maps. Will zip the two collections and join each subentities
with their respective parents by join-key
and store the result at the slot
key in each entity. If at least one entity match with multiple
subentities (one-to-many), then the slot
will be a list of subentities, a
single value otherwise.
E.g: (fold [(User {:id 1}) (User {:id 2})]
[(Profile {:user-id 1}) (Profile {:user-id 2})]
:profile
:user-id)
Take a list of `entities` that can be Identified, and a list of arbitrary `subentities` maps. Will zip the two collections and join each subentities with their respective parents by `join-key` and store the result at the `slot` key in each entity. If at least one entity match with multiple subentities (one-to-many), then the `slot` will be a list of subentities, a single value otherwise. E.g: (fold [(User {:id 1}) (User {:id 2})] [(Profile {:user-id 1}) (Profile {:user-id 2})] :profile :user-id)
(save! this db)
(save! this db opts)
Save an entity by its primary key.
Save an entity by its primary key.
(store this)
Typically return the table name where this entity should be stored.
Typically return the table name where this entity should be stored.
(super-init this)
(super-init this id-type)
Base behaviour of Initializable/init that will generate a primary key for an entity, you can call this function like you would call super(…) in OOP if you overload it.
Base behaviour of Initializable/init that will generate a primary key for an entity, you can call this function like you would call super(…) in OOP if you overload it.
(update! this db where-clause)
(update! this db where-clause opts)
Usefull to update multiple entities of the same kind by an arbitrary predicate. Use Savable/save! if your predicate is to update by primary key.
Usefull to update multiple entities of the same kind by an arbitrary predicate. Use Savable/save! if your predicate is to update by primary key.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close