Composite keys


We have an entity with a composite key that we’d like to remain unique within the database. The Datomic Cloud documentation mentions

Datomic does not provide a mechanism to declare composite uniqueness constraints; however, you can implement them (or any arbitrary functional constraint) via transaction functions.

Is there some example of this? I’m guess that we should use :db/cas but it’s not clear how. Can we write our own transaction functions?


You can use Datomic Ions to implement transaction functions in Datomic Cloud.

The code in the Ion transaction function is entirely up to you, so you can implement your required constraints however you prefer.