asami

Jakub Holý (HolyJak) 2022-03-24T16:36:00.884079Z

It isn't clear to me from https://github.com/quoll/asami/wiki/4.-Transactions#temporary-ids whether temporary IDs must be negative longs or what are the requirements. Anyone knows? 🙏

quoll 2022-03-24T16:36:50.207009Z

Negative integer values

👍 1
🙏 1
Jakub Holý (HolyJak) 2022-03-24T16:38:48.234949Z

thx! Have mentioned that in the wiki

quoll 2022-03-24T16:40:03.022369Z

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) 2022-03-24T17:23:15.560369Z

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.

quoll 2022-03-24T18:19:23.369459Z

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

quoll 2022-03-24T18:22:47.097239Z

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]

quoll 2022-03-24T18:23:29.632389Z

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) 2022-03-25T13:04:06.723429Z

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

👍 1