Liking cljdoc? Tell your friends :D

aggregate.core


->1clj

(->1 relation-kw entity-kw)
(->1 relation-kw entity-kw options)

Returns a relation-spec for a :one> relationship. Available options: :fk-kw A keyword denoting the foreign-key name. :owned? A boolean telling if the related entity is owned, i.e. will be deleted when the owner or the link is deleted. Defaults to true.

Returns a relation-spec for a :one> relationship.
Available options:
:fk-kw            A keyword denoting the foreign-key name.
:owned?           A boolean telling if the related entity is owned,
                  i.e. will be deleted when the owner or the link is
                  deleted. Defaults to true.
sourceraw docstring

->mnclj

(->mn relation-kw entity-kw)
(->mn relation-kw entity-kw options)

Returns a relation-spec for a :<many> relationship. Available options: :query-fn A function returning records by a foreign key. :update-links-fn A function for updating link table records. :owned? A boolean telling if the related entity is owned, i.e. will be deleted when the owner or the link is deleted. Defaults to false.

Returns a relation-spec for a :<many> relationship.
Available options:
:query-fn         A function returning records by a foreign key.
:update-links-fn  A function for updating link table records.
:owned?           A boolean telling if the related entity is owned,
                  i.e. will be deleted when the owner or the link is
                  deleted. Defaults to false.
sourceraw docstring

->nclj

(->n relation-kw entity-kw)
(->n relation-kw entity-kw options)

Returns a relation-spec for a :<many relationship. Available options: :fk-kw A keyword denoting the foreign-key name. :query-fn A function returning records by a foreign key. :owned? A boolean telling if the related entity is owned, i.e. will be deleted when the owner or the link is deleted. Defaults to true.

Returns a relation-spec for a :<many relationship.
Available options:
:fk-kw            A keyword denoting the foreign-key name.
:query-fn         A function returning records by a foreign key.
:owned?           A boolean telling if the related entity is owned,
                  i.e. will be deleted when the owner or the link is
                  deleted. Defaults to true.
sourceraw docstring

delete!clj

(delete! er-config db-spec m)
(delete! er-config db-spec entity-kw m-or-id)

Removes an aggregate datastructure from the database. Returns the number of deleted records.

Removes an aggregate datastructure from the database.
Returns the number of deleted records.
sourceraw docstring

entityclj

(entity & args)

Returns an entity-spec from an entity keyword, an optional options-map and an arbitrary number of relation-specs, i.e. (agg/entity entity-kw options-map? relations) Available options: :read-fn A function (fn [db-spec id]) returning the record with primary key value id as a map. :insert-fn A function (fn [db-spec row-map]) that inserts the row-map as record, and returns the row-map containing the new primary key value. :update-fn A function (fn [db-spec set-map]) that updates the record identified by the primary key value within set-map with the values of set-map. :delete-fn A function (fn [db-spec id]) that deletes the record identified by the primary key value. :id-kw The keyword to be used to get/assoc the primary key value. It is also used as primary key column name in default DB access functions.

Returns an entity-spec from an entity keyword, an optional
options-map and an arbitrary number of relation-specs, i.e.
    (agg/entity entity-kw options-map? relations)
Available options:
:read-fn       A function (fn [db-spec id]) returning the
               record with primary key value id as a map.
:insert-fn     A function (fn [db-spec row-map]) that inserts
               the row-map as record, and returns the row-map
               containing the new primary key value.
:update-fn     A function (fn [db-spec set-map]) that updates
               the record identified by the primary key value
               within set-map with the values of set-map.
:delete-fn     A function (fn [db-spec id]) that deletes the
               record identified by the primary key value.
:id-kw         The keyword to be used to get/assoc the primary
               key value. It is also used as primary key
               column name in default DB access functions.
sourceraw docstring

extract-idclj

(extract-id id-kw insert-result)

Extracts id value from results like ({:scope_identity() 2}) or ({:id 2, ...}).

Extracts id value from results like ({:scope_identity() 2}) or ({:id 2, ...}).
sourceraw docstring

loadclj

(load er-config db-spec m)
(load er-config db-spec entity-kw id)

Loads an aggregate by id. The entity-kw denotes the aggregate root. Returns a map containing the entity-kw in ::entity and all data, or nil if the entity-kw is unknown or the record does not exist.

Loads an aggregate by `id`. The `entity-kw` denotes the aggregate root.
Returns a map containing the entity-kw in ::entity and all data, or
nil if the entity-kw is unknown or the record does not exist.
sourceraw docstring

make-delete-fnclj

(make-delete-fn tablename id-kw)

Returns a delete function [db-spec id -> (Seq id)] for a specific table, which deletes the record id points to. It returns the number of deleted records (usually 1), or nil if none was deleted. The tablename may be passed as string or keyword.

Returns a delete function [db-spec id -> (Seq id)] for a specific
table, which deletes the record id points to. It returns the number
of deleted records (usually 1), or nil if none was deleted.
The tablename may be passed as string or keyword.
sourceraw docstring

make-entity-optionsclj

(make-entity-options tablename)
(make-entity-options tablename id-kw)

Returns a map containing all four default JDBC based implementations for read, insert, update and delete.

Returns a map containing all four default JDBC based implementations
for read, insert, update and delete.
sourceraw docstring

make-er-configclj

(make-er-config & args)

Creates a er-config map from an optional options-map and an arbitrary number of entity-specs, i.e. (agg/make-er-config options-map? entities) Available options: :read-fn-factory A function (fn [tablename]) returning the default read function. :insert-fn-factory A function (fn [tablename]) returning the default insert function. :update-fn-factory A function (fn [tablename]) returning the default update function. :delete-fn-factory A function (fn [tablename]) returning the default delete function. :query-<many-fn-factory A function (fn [tablename fk-kw]) returning the default query-for-many function using one foreign key. :query-<many>-fn-factory A function (fn [tablename linktablename fk-a fk-b]) returning the default query-for-many function that uses a linktable. :update-links-fn-factory A function (fn [linktablename fk-a fk-b]) returning the default function to update link tables. :id-kw A keyword that is taken as default primary key column name. :persisted-pred-fn A predicate (fn [db-spec entity-kw id-kw row-map]) that returns true if the given row-map is already present in DB.

Creates a er-config map from an optional options-map and an
arbitrary number of entity-specs, i.e.
    (agg/make-er-config options-map? entities)
Available options:
:read-fn-factory          A function (fn [tablename]) returning the
                          default read function.
:insert-fn-factory        A function (fn [tablename]) returning the
                          default insert function.
:update-fn-factory        A function (fn [tablename]) returning the
                          default update function.
:delete-fn-factory        A function (fn [tablename]) returning the
                          default delete function.
:query-<many-fn-factory   A function (fn [tablename fk-kw]) returning
                          the default query-for-many function using
                          one foreign key.
:query-<many>-fn-factory  A function (fn [tablename linktablename fk-a fk-b])
                          returning the default query-for-many function
                          that uses a linktable.
:update-links-fn-factory  A function (fn [linktablename fk-a fk-b])
                          returning the default function to update
                          link tables.
:id-kw                    A keyword that is taken as default primary
                          key column name.
:persisted-pred-fn        A predicate (fn [db-spec entity-kw id-kw row-map])
                          that returns true if the given row-map is already
                          present in DB.
sourceraw docstring

make-insert-fnclj

(make-insert-fn tablename id-kw)

Returns an insert function [db-spec row-map -> row-map] for a specific table. It returns the record, possibly augmented with the generated id in an :id slot. The tablename may be passed as string or keyword.

Returns an insert function [db-spec row-map -> row-map] for a specific table.
It returns the record, possibly augmented with the generated id in
an :id slot. The tablename may be passed as string or keyword.
sourceraw docstring

make-query-<many-fnclj

(make-query-<many-fn tablename fk-kw)

Returns a finder function [db-spec id -> (Seq Map)] for a specific table, that returns -- as sequence of maps -- all records that have id as value of the foreign key field denoted by fk-kw. Assumes a simple n to 1 relationship.

Returns a finder function [db-spec id -> (Seq Map)] for a specific
table, that returns -- as sequence of maps -- all records that have
id as value of the foreign key field denoted by fk-kw.
Assumes a simple n to 1 relationship.
sourceraw docstring

make-query-<many>-fnclj

(make-query-<many>-fn tablename linktablename fk-a fk-b)
(make-query-<many>-fn tablename linktablename fk-a fk-b b-id-kw)

Returns a finder function [db-spec id -> (Seq Map)] for a specific table whose records are in a m to n relationship realized by a link table containing two foreign keys. The function returns a sequence of maps.

Returns a finder function [db-spec id -> (Seq Map)] for a
specific table whose records are in a m to n relationship
realized by a link table containing two foreign keys. The
function returns a sequence of maps.
sourceraw docstring

make-read-fnclj

(make-read-fn tablename id-kw)

Returns a read function [db-spec id -> row-map] for a specific table. It returns a single record or nil. The tablename may be passed as string or keyword.

Returns a read function [db-spec id -> row-map] for a specific table.
It returns a single record or nil. The tablename may be passed as
string or keyword.
sourceraw docstring

make-update-fnclj

(make-update-fn tablename id-kw)

Returns an update function [db-spec set-map -> set-map] for a specific table, which takes a map of values and updates the record denoted by the :id contained in set-map. It returns the set-map. The tablename may be passed as string or keyword.

Returns an update function [db-spec set-map -> set-map] for a
specific table, which takes a map of values and updates the record
denoted by the :id contained in set-map. It returns the set-map.
The tablename may be passed as string or keyword.
sourceraw docstring

(make-update-links-fn linktablename fk-a fk-b)
(make-update-links-fn linktablename fk-a fk-b b-id-kw)

Returns a function that updates a link table by first deleting all records having a-id as value in the field fk-a, and afterwards inserting for each of the bs one record with fk-a = a-id and fk-b = (:id b).

Returns a function that updates a link table by first deleting all
records having a-id as value in the field fk-a, and afterwards
inserting for each of the bs one record with fk-a = a-id and fk-b
= (:id b).
sourceraw docstring

onlyclj

(only er-config & entity-relation-seqs)

Removes all relations that are NOT specified by the vectors. A vector must begin with an entity-kw, all remaining items denote relations.

Removes all relations that are NOT specified by the vectors.
A vector must begin with an entity-kw, all remaining items denote
relations.
sourceraw docstring

persisted?clj

(persisted? db-spec entity-kw id-kw m)

Returns true if the map m has already been persisted. It is assumed that the existence of an id-kw key is enough evidence.

Returns true if the map m has already been persisted.
It is assumed that the existence of an id-kw key is enough evidence.
sourceraw docstring

save!clj

(save! er-config db-spec m)
(save! er-config db-spec entity-kw m)

Saves an aggregate data structure to the database.

Saves an aggregate data structure to the database.
sourceraw docstring

withoutclj

(without er-config & entities-or-entity-relation-seqs)

Removes entities (specified by a keyword) and relations (specified in a vector, where the first item is the entity keyword) from the er-config.

Removes entities (specified by a keyword) and relations (specified
in a vector, where the first item is the entity keyword) from the er-config.
sourceraw docstring

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

× close