We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Asami is schema-less, but during transactions it can be useful to incorporate schema information. For instance:
(transact conn {:tx-data [{:db/ident "first" :data 1}]}) (transact conn {:tx-data [{:db/ident "first" :data 42}] :schema {:db/ident :data :db/cardinality :db/cardinality/one})
By indicating a cardinality of one, this is equivalent to using an update annotation on the :data attribute.
:data
(entity conn "first")
{:data 42} Without the schema, this would have resulted in: {:data #{1 42}}
{:data 42}
{:data #{1 42}}
Also, data integrity can be checked:
(transact conn {:tx-data [{:db/ident "first" :data "forty-two"}] :schema {:db/ident :data :db/valueType :db.type/long})
This would throw an ExceptionInfo, with a message like: Attribute :data cannot accept data: "forty-two". Requires Long value.
ExceptionInfo
Attribute :data cannot accept data: "forty-two". Requires Long value.
These changes will occur in asami.entities
asami.entities
The text was updated successfully, but these errors were encountered:
A more important feature is:
(transact conn {:tx-data [{:db/ident "first" :data "forty-two" :sub {:data "sub-entity"}}]) (entity conn "first")
Result: {:data "forty-two" :sub {:data "sub-entity"}} (This is the current behavior)
{:data "forty-two" :sub {:data "sub-entity"}}
An important new database function will be :db/retractEntity, and this relies on schema:
:db/retractEntity
(transact conn {:tx-data [[:db/retractEntity [:db/ident "first"]]] :schema {:db/ident :sub :db/valueType :db.type/ref :db/isComponent true}}) (entity conn "first")
Result: nil
nil
(q '[:find [?e ...] :where [?e :data ?d]] conn)
Result: () (Currently, removing the top level object will still leave the "sub-entity" object alone)
()
Sorry, something went wrong.
No branches or pull requests
Asami is schema-less, but during transactions it can be useful to incorporate schema information. For instance:
By indicating a cardinality of one, this is equivalent to using an update annotation on the
:data
attribute.{:data 42}
Without the schema, this would have resulted in:
{:data #{1 42}}
Also, data integrity can be checked:
This would throw an
ExceptionInfo
, with a message like:Attribute :data cannot accept data: "forty-two". Requires Long value.
These changes will occur in
asami.entities
The text was updated successfully, but these errors were encountered: