A number used for ordering changes that happened in the same transaction. The order of changes observed in the output does not necessarily correspond to the order in which changes were applied during the transaction.
What does this mean?
I want use seq order to generate cypher, so the order is important.
For ex:
If I run these 3 cypher in a transaction.
I cant really think how the relationship creation would occur 1st since for the relationship to be created the 2 nodes in seq 1 and seq 2 have to be created 1st. or maybe im misreading/misunderstanding
again not sure how u can create a realtionship and to which a relationship is predicated on the existence of a starting and end node, but yet the starting/end node have not been created
so in this case you'd see the create event first, followed by the delete event - even though the node deletion was the first operation in the transaction
A number used for ordering changes that happened in the same transaction. The order of changes observed in the output does not necessarily correspond to the order in which changes were applied during the transaction.
Could you explain a bit more about the generated cypher and what you plan to do with it? Might help me give some better answers
On elementId - it is unique to an entity at a certain point in time, i.e. if there is a node/rel with that ID, then no other node/rel will have that ID in the database at the same time. If that entity gets deleted, then the elementId it had will get reused at some point in the future. This is why they shouldn't be used as persistent IDs in external systems
Sure, what I plan to do is undo/redo feature like many editors have, for ex: Microsoft word.
Sry, but I am not asking the explanation for the elementId, I am asking how the elementId help me in this case, because it's 100% outside the transaction.
For your use case - you're correct in that elementId isn't going to help you unfortunately
From what you've described , it looks like you'd need your ID property to be unique for the undo-redo to work with the order of the CDC events. Some monotonically increasing ID should work
The state that gets maintained during a transaction contains the logical changes that would happen rather than the physical operations that were performed.
As the CDC events are generated from this tx state before they are applied to the store, all execution order has been lost at this point.
So something like this pseudo code when creating entities
CREATE (newn {id:counter++})
where counter is always increasing. This way, a delete of the entity will always be for that entity alone. Managing that counter across multiple machines is a different problem though ...
Another option would be to use a UUID - you get the same outcome in that each entity would always get a unique ID so there would never be a risk of a delete acting on the wrong entity. Whilst much easier to implement, the property/value might not be something you want in your model
Oops, so your solution is still based on Node id.
I thought it will based on event.
Recreate biz logic just one of logic came in my mind when I found out the seq order issue.
Also the unique id way won't help if there is another property in the node that have unique constraint.
Now I guess you may suggest we always do delete event first when undo, but who knows if there is another issue to do that.
Anyway, without reliable order, I think we need to review all our biz logic to ensure the "order way" won't affect us