JackAdams / meteor-transactions

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

Collection.insert should not mutate the caller's newDoc object. #68

Closed mattmccutchen closed 7 years ago

mattmccutchen commented 7 years ago

The mutation broke our app here, where we created the keyFields object, inserted it as a document, and later used it as a selector, intending to find the same document. Since the transaction package set keyFields.transaction_id and the transaction ID of the document in the database had been changed by the intervening update, the selector didn't match. One could argue that our code is dodgy, but I think there's a stronger general principle that API calls should not mutate their arguments unless documented as doing so.

Note: I tested that in combination with #67 (ignoring the other four test failures), the new test fails on the old code and passes on the new code.