asami

lilactown 2022-02-26T05:36:52.567869Z

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?

quoll 2022-02-26T17:21:16.854319Z

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
lilactown 2022-02-26T17:48:36.208199Z

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

quoll 2022-02-26T17:49:35.816409Z

This was a contribution last year! 🙂

quoll 2022-02-26T17:50:58.085349Z

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