How would I do a transaction that works like SQL INSERT INTO foo VALUES (...) ON CONFLICT DO NOTHING ? I don't want to do an upsert. I want the first value in the database to win
https://docs.datomic.com/transactions/transaction-functions.html#dbfn-cas
> You can use nil for the old value to specify that the new value should be asserted only if no value currently exists.
I think is what you want
oh wait but you want "do nothing"
What should the entity id be when I expect the entity to not be there?
nil works, but cas will throw
just mark an attribute unique. transaction sends in an entity with a tempid
no need for txfn. If you try to transact a novel entity with a value already associated with another entity, the transaction will be rejected.
unique by value you mean? that throws too (which, you can catch, but doesn't quite do what the sql does)
any transaction that is aborted "throws" -- so what?
It seems to do an upsert on the second insert if I just depend on the attribute being unique
I want the second insert to do nothing
@eoogbe you gotta use unique by value (as opposed to unique by id)
just paste what you typed, what the schema is, and what the result was.
you can make a txn fn that doesn't throw is my only additional contribution, but that may not be important to Eva.
Can I use unique by value in lookup refs?
https://docs.datomic.com/schema/identity.html#unique-values > Unique values have the same semantics as unique identities, with one critical difference: Attempts to assert a new tempid with a unique value already in the database will cause an IllegalStateException. It looks that way. I don't use them often, so I've not tested it myself.
Ok great I will change it to use unique by value and catch the error
Thanks