László Török
2015-02-10 17:30:59 UTC
Hi,
there basically two ways (I can think of):
You declare a new attribute with a :db.unique/value constraint. When you
add a new entity to the database, you make sure that you also compute the
value of this attribute and include in the transaction. The transaction
will fail if the uniqueness constraint is violated, and you can retry. (You
can also do a "pre-flight" using datomic.api/with as it is a cheaper way of
finding it out on the peer).
The other way of doing it, is on the transactor. You need to declare a
transaction function [1] that will run inside the transactor. There you can
run your checks and fail if they are violated.
Hope it helps
[1] http://docs.datomic.com/database-functions.html
there basically two ways (I can think of):
You declare a new attribute with a :db.unique/value constraint. When you
add a new entity to the database, you make sure that you also compute the
value of this attribute and include in the transaction. The transaction
will fail if the uniqueness constraint is violated, and you can retry. (You
can also do a "pre-flight" using datomic.api/with as it is a cheaper way of
finding it out on the peer).
The other way of doing it, is on the transactor. You need to declare a
transaction function [1] that will run inside the transactor. There you can
run your checks and fail if they are violated.
Hope it helps
[1] http://docs.datomic.com/database-functions.html
Can someone shed some light on how to implement composite keys for a
Datomic entity? Any hint/help is much appreciated. I understand Datomic
entity is essentially the ID, and we only store the fact/attribute. But in
my case, the requirement is to make sure a fact exists only along with
couple of other facts, and those facts together point to a thing in my
domain (an Entity and its composite/primary key). I can also have a UUID
attribute for this entity, and use that for my future lookups.
The Datomic document states this - " Datomic does not provide a mechanism
to declare composite uniqueness constraints; however, you can implement
them (or any arbitrary functional constraint) via transaction functions
<http://docs.datomic.com/database-functions.html>."
Again, any help/suggestion is much appreciated. Thanks
-Hari
--
You received this message because you are subscribed to the Google Groups
"Datomic" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
Datomic entity? Any hint/help is much appreciated. I understand Datomic
entity is essentially the ID, and we only store the fact/attribute. But in
my case, the requirement is to make sure a fact exists only along with
couple of other facts, and those facts together point to a thing in my
domain (an Entity and its composite/primary key). I can also have a UUID
attribute for this entity, and use that for my future lookups.
The Datomic document states this - " Datomic does not provide a mechanism
to declare composite uniqueness constraints; however, you can implement
them (or any arbitrary functional constraint) via transaction functions
<http://docs.datomic.com/database-functions.html>."
Again, any help/suggestion is much appreciated. Thanks
-Hari
--
You received this message because you are subscribed to the Google Groups
"Datomic" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
László Török
--
Checkout http://www.lollyrewards.com/
--
You received this message because you are subscribed to the Google Groups "Datomic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to datomic+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
László Török
--
Checkout http://www.lollyrewards.com/
--
You received this message because you are subscribed to the Google Groups "Datomic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to datomic+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.