e-oj / Fawn

Transactions for MongoDB (See the README)
https://www.npmjs.com/package/fawn
MIT License
486 stars 54 forks source link

Fawn only updates a single document even thgough multiple documents match the search criteria #69

Closed lahiruchandima closed 6 years ago

lahiruchandima commented 6 years ago

I use following to update a collection with Fawn.

dbTransactionTask.update('receipts', {owner: owner, branch: branch}, {closed: true});

My expectation is that Fawn would update all documents matching criteria {owner: owner, branch: branch}. But, fawn only updates a single document which matches the criteria. All other documents matching criteria remains untouched.

Is this the expected behavior? Is there any way to get all documents to update?

e-oj commented 6 years ago

You need to set the multi option to true

task.update(...).options({multi: true})

Documented here

e-oj commented 6 years ago

I will be closing this issue. Feel free to reopen If you're still having trouble with the updates.