Closed begor closed 3 years ago
Hi @begor, when a new object is created using a make*
operation, the ID of the new object is the OpId of the operation that created it. That OpId is not included in the operation since it's redundant (in the sense that it can be computed from other fields), although we could consider adding it if that makes life easier.
Your code for computing the OpIds is not quite correct: the first OpId in a change is
`${change.startOp}@${change.actor}`
and then number before the @
is incremented for subsequent ops. That is, you need to start with change.startOp
, not with change.seq
.
Thanks a lot, Martin!
With #426 now merged, it's now easy to do ${change.startOp}@${change.actor}
, so there's probably no need in adding it to Op
.
Hey folks!
I've noticed that if you use
automerge.getHistory(doc)
API, you won't get IDs of objects that were created.Consider a toy example:
We'll get:
It turns out for operations like
makeMap
:we don't include
objId
for that newly created map. We only include it for operations that actually mutate the map:After some thought it looks like we should be able to reconstruct id from
change.actor
andchange.seq
with the following logic:Two questions: 1) Is this a correct approach? 2) Why
Operation
doesn't includeOpId
in the first place? Is purely to optimize the size ofOperation
struct?Thanks in advance!