Fork me on GitHub
#datomic
<
2020-12-10
>
tatut07:12:25

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.

onetom06:12:54

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.

kenny16:12:19

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.

tvaughan19:12:31

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

favila20:12:54

You will get an entity ID and no database, so no, you cannot use an attr predicate for this

favila20:12:22

you need :db/ensure to enforce something like this safely and atomically

chicwayne20:12:56

@U09R86PA4, 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?

favila20:12:49

I’m not sure what you mean? entity id returned from what?

chicwayne20:12:39

Maybe I'm misinterpreting what you meant by > You will get an entity ID

chicwayne20:12:19

Can you elaborate?

chicwayne20:12:57

I took it as the answer to @U0P7ZBZCK question below. > If so, what would be passed to the predicate function?

favila20:12:19

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

favila20:12:13

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