Fork me on GitHub
#datomic
<
2016-01-29
>
bplatz00:01:47

Thanks Stuart, glad to get a second opinion on it. It just felt like maybe I was missing something, but I guess not!

serioga12:01:40

@meow: I did smth like this: - run transactor.cmd with dev-transactor-template.properties - run shell.cmd and import demo data in there - run console.cmd to see console in browser Then I was able to see smth in action simple_smile But documentation is not clear here šŸ˜ž https://clojurians.slack.com/archives/datomic/p1453931405000091

misha15:01:52

@robert-stuttaford: greetings! I saw you asked @tonsky whether datomic<->datascript sync is a solved problem or not. What is the outcome of that? Are there any good approaches, or did it turn out to be way to specific to a particular project needs to have something useful to share? thanks

jgdavey20:01:33

Has anyone ever had to implement something thatā€™s just like :db.fn/cas, only retracts the fact if and only if the current value matches? Bascially, allowing ā€œnew valueā€ to be effectively nil?

jgdavey20:01:15

I basically want "compare-and-retract"

marshall20:01:49

@jgdavey: You can simply issue a retraction.

marshall20:01:10

@jgdavey: If the value in the [:db/retract E A V] doesnt match, you just get an empty transaction

jgdavey20:01:14

That works when the fact exists.

jgdavey20:01:43

It doesnā€™t ā€œblow upā€ like cas if there is no fact to retract

marshall20:01:27

i.e. you want something to throw or error if you try to retract a non-existant value?

jgdavey20:01:39

The specific thing is: I have an expirable token. When that token is used in one transaction, and is retracted in the same transaction.

jgdavey20:01:33

I want to ensure that token is valid (in an atomic sense) so that it canā€™t be used twice

jgdavey20:01:50

I was thinking in terms of cas, but maybe thereā€™s another way

marshall20:01:08

Ah. Iā€™d say probably a good candidate for a check and retract inside a custom tx function

jgdavey20:01:26

And just throw if itā€™s gone?

marshall20:01:36

if thatā€™s your desired behavior

marshall20:01:49

that will abort the whole transaction

jgdavey20:01:55

Is that the correct way to abort a transaction?

marshall20:01:05

specifies that "You can use them to ensure atomic read-modify-update processing, and integrity constraints. (To abort a transaction, simply throw an exception)."

jgdavey20:01:15

Gotcha. Thanks!

marshall20:01:02

This page http://docs.datomic.com/exceptions.html also provides some additional info on how exceptions are propagated back to the peer from the transactor

jgdavey20:01:28

FYI, hereā€™s what I came up with:

marshall20:01:58

seems reasonable to me