Fork me on GitHub
#datomic
<
2018-04-11
>
johnj15:04:48

how do you enforce constraints in datomic cloud?

Alex Miller (Clojure team)15:04:39

what kind of constraints do you mean?

johnj16:04:46

like a payment can be registered only if a customer exists

eraserhd16:04:13

I have a mechanism for doing this, but there's nothing built in to Datomic.

eraserhd16:04:31

Essentially, I have a transaction function that runs in the transactor, and it gets passed the tx. It uses d/with to build a db with the tx, then enumerates the constraints queries in the database, and ensures that none of them return data.

eraserhd16:04:01

If successful, it returns the tx as-is. Otherwise, it fails with a nice error message.

eraserhd16:04:36

I'm looking for things to extract from my (overly large) project. Perhaps this is a nice thing.

johnj16:04:37

ah, you pass custom code to the transactor, is this supported in cloud?

eraserhd17:04:25

Hmm... I don't know. I mean, I'll bet you can install transaction functions, but I don't know much about cloud.

mynomoto17:04:39

Afaik no custom transaction function on cloud.

Alex Miller (Clojure team)18:04:10

This will be an evolving area of cloud

hmaurer20:04:36

@alexmiller do you have a rough timeframe for this?