In datomic cloud is it possible to use with-db
in transaction function? It requires a connection but the tx fn is only passed a db value.
maybe you can call datomic.client.api/with
on that db value you receive in the transaction function?
I would be curious to know whether it works or not.
fyi, I just ran into this too 🙂 Created a question on ask.datomic https://ask.datomic.com/index.php/557/can-you-use-d-with-inside-a-cloud-transaction-function.
Is it possible to use an attribute predicate on a ref? If so, what would be passed to the predicate function? Our desire is to limit the reference based on a value of an attribute in the referenced entity. I think the answer is no, but we're not reading the documentation the same. We'd really appreciate a clarification, thanks
You will get an entity ID and no database, so no, you cannot use an attr predicate for this
you need :db/ensure
to enforce something like this safely and atomically
Great. Thank you @favila
@favila, what if the entity ID returned consists of a single attribute/value pair with :db.unique/value, i.e. the related schema was purposely designed to have only one attribute with a unique value, would that change your answer in any way?
I’m not sure what you mean? entity id returned from what?
Maybe I'm misinterpreting what you meant by > You will get an entity ID
Can you elaborate?
I took it as the answer to @tvaughan question below. > If so, what would be passed to the predicate function?
The contract for attribute predicates is (fn [v] ) => true (to allow) | anything-else (to reject), where v is the value that will be asserted/retracted. For refs, that value is a long representing an entity id
attribute predicates must decide to accept or reject based only on the value. without a database it can’t learn anything about what is asserted for the entity
Thanks @favila.