JackAdams / meteor-transactions

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

Documentation misleading on where to put the tx.update() for $set commands? #4

Closed ljmatkins closed 9 years ago

ljmatkins commented 9 years ago

In the docs I believe the following lines should be swapped so that tx.update occurs before Posts.update:

Posts.update({_id:post_id},{$set:{text:"My improved post"}}); tx.update(Posts,post_id,{$set:{text:"My improved post"}});

As it is now, the inverse action is populated with the new value instead of the old, and the undo operation does not actually end up changing anything.

JackAdams commented 9 years ago

Yeah, I see now that the docs are a bit confusing. Those two lines of code are supposed to be either-or, not both-and. The first line is how to do it the usual way. The second line is how to do the same thing using the transactions package, so that it's undoable at the click of a button.

I'd advise holding off using this package for now. I'm planning a rewrite of it at some stage to make an API that integrates better with existing Meteor patterns and doesn't kind of take over your whole app.