meteor-transactions
meteor-transactions copied to clipboard
Cannot undo an insertion after undoing a later update to same document
If a document is inserted in one transaction and updated in a second transaction, and then I try to undo both transactions in reverse order, the undo of the insertion will fail because the transaction_id of the doc doesn't match. Test case.
In my app, I disabled this check because the app enforces a linear undo history. I'm not sure what would be an appropriate fix in general. One idea: keep a list of all transaction IDs that have updated the document after it was inserted. When one of those transactions is undone, remove it from the list. When attempting to undo the insertion, check that the list is empty. But this list could grow indefinitely, which could become a problem.
I don't have a good solution for this. The list of transaction id values would work but, like you say, it would blow out the size of documents with lots of writes done on them via transactions.
We could control the indefinite growth of transaction_id arrays by cleaning up old transactions with a cron job and removing transaction_id values from documents affected by the transactions being removed. Not ideal.