JackAdams / meteor-transactions

App level transactions for Meteor + Mongo
http://transactions.taonova.com/
MIT License
113 stars 16 forks source link

Support upserts #84

Open mattmccutchen opened 7 years ago

mattmccutchen commented 7 years ago

This package could support upserts. Starting an issue thread to collect information.

As per my remarks here, if we're willing to represent an upsert in the history as either an insert or an update, then it's pretty straightforward to emulate the upsert by checking for an existing document and deciding whether to insert or update. The only tricky part is constructing the document to insert from the selector and the modifier. Meteor has two implementations of this (1, 2) that we can copy.

If we want to represent an upsert in the history as its own action type so it can be redone as an upsert, then it becomes more complicated to decide on and implement the undo and redo behavior.