Fork me on GitHub

say I have this collection of links to other entities like above. what's the best way for me to add those to the db as actual refs to the nodes? i.e. right now I add the string above, which I presume is a :db/ident that I can use in a query later. I'd rather have an actual ID of the node so that I can use it in first position in queries as well as use graphing capabilities. I could look up the node by ident before transacting. is that the best way?


I think I can understand your questions, so I’ll try to answer… The best way? Well, internally, the transaction needs to get the node id for the entity, so that this can go into the “subject” or “entity” position of a transacted triple. That can either be done by looking it up beforehand, or by including it in the transaction, by something like:

{:db/id [:db/ident "my-identifier] ...}
Whether you use a transaction syntax to do it, or if you do it yourself, the lookup is still needed. What’s “best” is probably to do it in the transaction, since there’s probably less round-trip overhead compared to your 2 calls. There’s also the (tiny) possibility of a race condition if you look it up yourself.

💡 1

ah! I didn't know I could use {:db/id [:db/ident ,,,,] ,,,,} to do refs.


This was a contribution last year! 🙂


I’m planning on working on Asami this afternoon. Are you going to be about much?