JackAdams / meteor-transactions

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

How to apply this package to my already existing collection? #45

Closed AndyHan1001 closed 8 years ago

AndyHan1001 commented 8 years ago

I have two collections, say A and B which are pure meteor collections without any {tx: true}, but now I want to perform transactions on these two collections A.remove() and B.update(). I always failed to do so. I have posted my debug info below:

I20151230-04:58:25.231(-8)? Started "delete answer" with transaction_id: aPDqgyHxYpdPMRJR9 I20151230-04:58:25.518(-8)? Document not found for removal: I20151230-04:58:25.520(-8)? { _id: undefined, deleted: { '$exists': false } } I20151230-04:58:25.921(-8)? Executed instant remove I20151230-04:58:26.119(-8)? Pushed update command to stack: aPDqgyHxYpdPMRJR9 I20151230-04:58:26.120(-8)? Beginning commit with transaction_id: aPDqgyHxYpdPMRJR9 I20151230-04:58:29.684(-8)? Executed update I20151230-04:58:29.882(-8)? Commit reset transaction manager to clean state

It said, Document not found for removal, but I can find it by mongo shell with the same selector.

JackAdams commented 8 years ago

You can't use mongo selectors in the normal way with this package. The selector must contain an _id value for a document from the collection. That's all that the package is looking for. Consequently, you can only update one document at a time with A.remove() or B.update().