Support for turning form deltas into Asami transactions etc.
Support for turning form deltas into Asami transactions etc.
(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>`
(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.
(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.
(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
(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 themselvestempid->generated-id
- mapping from Fulcro's tempids in delta to real, external IDs generated for the new entitiesThe 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.
(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
(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.
(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.
(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 ...}, ...}`.
(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.
(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
(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
(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.)
(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)
(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`
(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.
(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.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close