Liking cljdoc? Tell your friends :D

specomatic-db.core

The main namespace for consumers of specomatic-db. Contains functions for initialisation, retrieving and persisting entities.

The main namespace for consumers of specomatic-db. Contains functions for initialisation, retrieving and persisting entities.
raw docstring

by-idclj

(by-id env etype id)
(by-id env etype id fields)

Retrieves an entity by id. Returns nil if not found.

Retrieves an entity by id. Returns nil if not found.
sourceraw docstring

create!clj

(create! env etype entity)

Given the environment env, creates the entity of type etype in the database. Returns the given entity containing the new id and transaction id. Shape of env: {:jdbc database specification suitable for use with next.jdbc :config specomatic config :user {:id user id :permissions sequence of permissions :root? if user is root}}

Given the environment `env`, creates the `entity` of type `etype` in the database.
Returns the given `entity` containing the new id and transaction id.
Shape of `env`:
{:jdbc    database specification suitable for use with next.jdbc
 :config  specomatic config
 :user    {:id           user id
           :permissions  sequence of permissions
           :root?        if user is root}}
sourceraw docstring

default-fieldsclj

(default-fields schema etype)

Given schema and entity type etype, returns a seql vector of default fields.

Given `schema` and entity type `etype`, returns a seql vector of default fields.
sourceraw docstring

delete!clj

(delete! env etype id)

Given the environment env, delete the entity of type etype. Returns a map of id, :tx/id, nil if not found (might be due to permissions). Shape of env: {:jdbc database specification suitable for use with next.jdbc :config specomatic config :user {:id user id :permissions sequence of permissions :root? if user is root}}

Given the environment `env`, delete the `entity` of type `etype`.
Returns a map of id, :tx/id, nil if not found (might be due to permissions).
Shape of `env`:
{:jdbc    database specification suitable for use with next.jdbc
 :config  specomatic config
 :user    {:id           user id
           :permissions  sequence of permissions
           :root?        if user is root}}
sourceraw docstring

entity-historyclj

(entity-history env etype id fields)

Retrieves the full history of an entity.

Retrieves the full history of an entity.
sourceraw docstring

init!clj

(init! env)
(init! env {:keys [:skip-migration?]})

Given the environment env, does all necessary initialization. To skip automatic database schema migration, pass {:skip-migration? true} as a second argument. Currently validates the schem, initializes transaction infrastructure, ensures access control views exist and registers coercion functions.

Given the environment `env`, does all necessary initialization.
 To skip automatic database schema migration, pass `{:skip-migration? true}` as a second argument.
Currently validates the schem, initializes transaction infrastructure, ensures access control views exist and registers coercion functions.
sourceraw docstring

queryclj

(query env etype)
(query env etype fields)
(query env etype fields conditions)

Given the environment env, retrieves the seql fields from the etype entities matching the HoneySQL conditions. Optionally, the root entity may contain verbs like :verb/read, :verb/update as fields in addition to seql fields. These contain a boolean indicating whether or not the user (given by [:user :id] in env) is allowed to do what the verb describes with the specific entity. Shape of env: {:jdbc database specification suitable for use with next.jdbc :config specomatic config :user {:id user id :permissions sequence of permissions :root? if user is root}}

Given the environment `env`, retrieves the seql `fields` from the `etype` entities matching the HoneySQL `conditions`.
Optionally, the root entity may contain verbs like :verb/read, :verb/update as fields in addition to seql fields.
These contain a boolean indicating whether or not the user (given by [:user :id] in `env`) is allowed to do what the verb describes with the specific entity.
Shape of `env`:
{:jdbc    database specification suitable for use with next.jdbc
 :config  specomatic config
 :user    {:id           user id
           :permissions  sequence of permissions
           :root?        if user is root}}
sourceraw docstring

save!clj

(save! env etype entity)

Given the environment env, saves the entity of type etype into the database. Tries to create the entity if its id field is nonexistent or nil. Tries to update the entity if it has an id. Returns the given entity containing the new id (if created) and transaction id. Shape of env: {:jdbc database specification suitable for use with next.jdbc :config specomatic config :user {:id user id :permissions sequence of permissions :root? if user is root}}

Given the environment `env`, saves the `entity` of type `etype` into the database.
Tries to create the entity if its id field is nonexistent or nil.
Tries to update the entity if it has an id.
Returns the given `entity` containing the new id (if created) and transaction id.
Shape of `env`:
{:jdbc    database specification suitable for use with next.jdbc
 :config  specomatic config
 :user    {:id           user id
           :permissions  sequence of permissions
           :root?        if user is root}}
sourceraw docstring

save-related!cljmultimethod

Saves the changeset value for related entities contained in a relational field of a entity to the database. opts is a map of outer-etype and outer-id. If :specomatic.core/delete is true in the related entity, it is deleted. Otherwise, if the id field of the related entity is not nil, it is updated, if the id field is not present or nil, it is created. In the case of a reference collection of a has-many-through type, these mutations are applied to the join table, not the actual related entity.

Saves the changeset `value` for related entities contained in a relational `field` of a entity to the database.
`opts` is a map of outer-etype and outer-id.
If `:specomatic.core/delete` is true in the related entity, it is deleted.
Otherwise, if the id field of the related entity is not nil, it is updated, if the id field is not present or nil, it is created.
In the case of a reference collection of a has-many-through type, these mutations are applied to the join table, not the actual related entity.
sourceraw docstring

update!clj

(update! env etype entity)

Given the environment env, updates the entity of type etype in the database. Returns the given entity containing the transaction id. Shape of env: {:jdbc database specification suitable for use with next.jdbc :config specomatic config :user {:id user id :permissions sequence of permissions :root? if user is root}}

Given the environment `env`, updates the `entity` of type `etype` in the database.
Returns the given `entity` containing the transaction id.
Shape of `env`:
{:jdbc    database specification suitable for use with next.jdbc
 :config  specomatic config
 :user    {:id           user id
           :permissions  sequence of permissions
           :root?        if user is root}}
sourceraw docstring

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

× close