Liking cljdoc? Tell your friends :D

cz.holyjak.rad.database-adapters.asami.write

Support for turning form deltas into Asami transactions etc.

Support for turning form deltas into Asami transactions etc.
raw docstring

asami-lookup-ref->identclj

(asami-lookup-ref->ident lookup-ref)

The opposite of ident->asami-lookup-ref, i.e. [:id <ident>] -> <ident>

The opposite of [[ident->asami-lookup-ref]], i.e. `[:id <ident>] -> <ident>`
sourceraw docstring

attr-delta->before+after-setsclj

(attr-delta->before+after-sets env
                               attr-key
                               {:keys [before after] :as _attr-delta})

Returns the before and after of the delta as sets (or nil, if missing), whether singular or not. Thus downstream code doesn't need to care about arity.

Returns the before and after of the delta as sets (or nil, if missing), whether singular or not.
Thus downstream code doesn't need to care about arity.
sourceraw docstring

clear-singular-attributes-txnclj

(clear-singular-attributes-txn graph-or-db ident->singular-props)

Generate retractions for existing values of the given singular-props attributes of the given ident entities NOTE: It only clears the single attribute. If it points to a dependant entity, it remains in existence. Hopefully RAD handles removing those.

Generate retractions for existing values of the given `singular-props` attributes of the given `ident` entities
NOTE: It only clears the single attribute. If it points to a dependant entity, it remains in existence.
Hopefully RAD handles removing those.
sourceraw docstring

delta->singular-attrs-to-clearclj

(delta->singular-attrs-to-clear key->attribute schema delta)

Derives from the form delta and attribute definitions which singular attributes should be cleared of current value

Derives from the form delta and attribute definitions which singular attributes should be cleared of current value
sourceraw docstring

delta->txn-map-with-retractionsclj

(delta->txn-map-with-retractions
  {:com.fulcrologic.rad.attributes/keys [key->attribute] :as env}
  graph-or-db
  schema
  delta)

Turn Fulcro form delta into an Asami update transaction. Example delta (only one entry):

{[:account/id #uuid "ffffffff-ffff-ffff-ffff-000000000100"] {:account/active? {:before true, :after false}}}

Returns a map with two keys:

  • txn - the Asami transactions themselves
  • tempid->generated-id - mapping from Fulcro's tempids in delta to real, external IDs generated for the new entities

The transactions will include retractions for all involved singular attributes; the delta's :before value of such singular attributes is ignored.

Turn Fulcro form delta into an Asami update transaction. Example delta (only one entry):

{[:account/id #uuid "ffffffff-ffff-ffff-ffff-000000000100"]
 {:account/active? {:before true, :after false}}}

 Returns a map with two keys:
  - `txn` - the Asami transactions themselves
  - `tempid->generated-id` - mapping from Fulcro's tempids in delta to real, external IDs generated for the new entities

The transactions will include retractions for all involved singular attributes; the delta's
`:before` value of such singular attributes is ignored.
sourceraw docstring

delta->value-txnclj

(delta->value-txn {:keys [tempid->real-id] :as env+} schema delta)

Turn Fulcro delta for non-id attributes into Asami tx-data

Turn Fulcro delta for non-id attributes into Asami tx-data
sourceraw docstring

generate-idclj

(generate-id {:com.fulcrologic.rad.attributes/keys [key->attribute] :as _env}
             k
             suggested-id)

Generate an id for a new entity being saved. You need to pass a suggested-id as a UUID or a tempid. If it is a tempid and the ID column is a UUID, then the UUID from the tempid will be used.

Generate an id for a new entity being  saved. You need to pass a `suggested-id` as a UUID or a tempid.
If it is a tempid and the ID column is a UUID, then the UUID *from* the tempid will be used.
sourceraw docstring

ident->asami-lookup-refclj

(ident->asami-lookup-ref ident)
(ident->asami-lookup-ref tempid->real-id [key id :as ident])

Turn a Fulcro ident into something Asami interprets as an entity id / lookup reference NOTE: If this is a new entity then the metadata ::new? is added to it. See asami-lookup-ref->ident for the opposite.

Turn a Fulcro ident into something Asami interprets as an entity id / lookup reference
NOTE: If this is a new entity then the metadata `::new?` is added to it.
See [[asami-lookup-ref->ident]] for the opposite.
sourceraw docstring

keep-attr-deltasclj

(keep-attr-deltas attr-filter-fn key->attribute entity-delta)

Like core/keep on the seq of entity delta entries, but with the signature (fn [rad-attribute {:keys [before after]}]). Notice the rad-attribute could be nil, e.g. if not properly registered with Pathom. Here, entity-delta is typically the map {<qualified attr key> {:before .., :after ...}, ...}.

Like core/keep on the seq of entity delta entries, but with the signature `(fn [rad-attribute {:keys [before after]}])`.
Notice the rad-attribute could be `nil`, e.g. if not properly registered with Pathom.
Here, `entity-delta` is typically the map `{<qualified attr key> {:before .., :after ...}, ...}`.
sourceraw docstring

new-entity-ident->tx-dataclj

(new-entity-ident->tx-data ident)
(new-entity-ident->tx-data key->attribute [id-prop id-val :as ident])

Produce the tx-data for d/transact necessary to add a new entity - typically adding the ident's key and value as a property plus other required entity properties.

Produce the tx-data for `d/transact` necessary to add a new entity - typically adding the ident's key and value as
a property plus other required entity properties.
sourceraw docstring

non-id-schema-attr?clj

(non-id-schema-attr? target-schema attr)

The attribute belongs to the current schema (= DB) and is a normal property, i.e. not the ID

The attribute belongs to the current schema (= DB) and is a normal property, i.e. not the ID
sourceraw docstring

non-id-schema-prop?clj

(non-id-schema-prop? {:com.fulcrologic.rad.attributes/keys [key->attribute]}
                     target-schema
                     k)

The attribute belongs to the current schema (= DB) and is a normal property, i.e. not the ID

The attribute belongs to the current schema (= DB) and is a normal property, i.e. not the ID
sourceraw docstring

orphaned-owned-entities-retraction-txnclj

(orphaned-owned-entities-retraction-txn graph-or-db key->attribute delta)

Make a retraction txn including all 'owned' entities that their parents stopped referring to. (Essentially, implementing cascading delete.)

Make a retraction txn including all 'owned' entities that their parents stopped referring to.
(Essentially, implementing cascading delete.)
sourceraw docstring

prop-delta->tx-dataclj

(prop-delta->tx-data {:com.fulcrologic.rad.attributes/keys [] :as env+}
                     eid
                     k
                     attr-delta)

Turns a single delta for a single entity and property into transaction(s) (multiple if cardinality = many)

Turns a single delta for a single entity and property into transaction(s) (multiple if cardinality = many)
sourceraw docstring

retract-entityclj

(retract-entity conn id)

Retract a (flat) entity from the DB, given the value of its :id attribute (i.e, typically a Fulcro ident). Returns same as d/transact

Retract a (flat) entity from the DB, given the value of its `:id` attribute (i.e, typically a Fulcro ident).
Returns same as `d/transact`
sourceraw docstring

retract-entity-txnclj

(retract-entity-txn db ident)

Return the transaction data to retract a (flat) entity from the DB, given its ident.

BEWARE: Until https://github.com/quoll/asami/issues/5 is fixed, you might need to retract ID attributes separately in a subsequent transaction.

Return the transaction data to retract a (flat) entity from the DB, given its ident.

BEWARE: Until https://github.com/quoll/asami/issues/5 is fixed, you might need to retract ID
        attributes separately in a subsequent transaction.
sourceraw docstring

transact-generatedclj

(transact-generated connection tx-generator-fn)

EXPERIMENTAL. Like asami.core/transact but first generates the tx-data (sequence of triplets) via (tx-generator-fn graph). The generator is run when it has exclusive access to the storage, i.e. no other transaction will change the DB in the meantime.

Based on simplified and extended code of asami.core/transact does.

BEWARE: The DB is locked while tx-generator-fn runs so make it fast.

EXPERIMENTAL. Like asami.core/transact but first generates the _tx-data_ (sequence of triplets)
via `(tx-generator-fn graph)`. The generator is run when it has exclusive access to the storage,
i.e. no other transaction will change the DB in the meantime.

Based on simplified and extended code of `asami.core/transact` does.

BEWARE: The DB is locked while `tx-generator-fn` runs so make it fast.
sourceraw docstring

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

× close