Fork me on GitHub
Jakub Holý (HolyJak)16:03:00

It isn't clear to me from whether temporary IDs must be negative longs or what are the requirements. Anyone knows? 🙏


Negative integer values

👍 1
🙏 1
Jakub Holý (HolyJak)16:03:48

thx! Have mentioned that in the wiki


When the transaction process sees a negative integer as an ID, it allocates a new node, and maps that number to the node. Thereafter, if it sees that number again, it knows that you're looking for that node. At the end of the transaction, one of the things returned is a map of those negative numbers to the nodes that were allocated for them

👍 1
Jakub Holý (HolyJak)17:03:15

Perhaps this is a dumb question but if a transaction creates a new entity and also wants to add a reference to it to another entity, how does Asami know - in the face of having not schema - that the reference attribute value is actually a reference and not just a value? Does it automatically interet something like {:db/ident -1} as a reference and replaces it with the actual entity id? Example:

{:tx-data [[-1 :child/name "Joe"]
           [-1 :child/age 0]
           [#a/n 12 :parent/children {:db/ident -1}]]} ; <-- how to refer to the new child?
🙏 I guess I cannot just [#a/n 12 :parent/children -1]] because Asami cannot know that I mean a reference to an entity and not just a negative integer value.


This is true, but I decided to leave the ambiguity because it's: • often useful to refer to things this way • There is an alternative that can be used when values don't work for you. • It continues to look like Datomic by allowing negative numbers to make references like this. Note in your example, it should be {:db/id -1} and not :db/ident


Also, while I think that {:db/id -1} works (I haven't looked for a while), you should also be able to use node refs, which is [:db/id -1]


Please let me know if I'm wrong on any of this. I know I can look, but I'm in meetings all afternoon. If things aren't working right, then I can focus on it when I'm next on this stuff

Jakub Holý (HolyJak)13:03:06

I will have a look, no worry! Thanks a lot for your help!!!

👍 1