In mongodb, I have the following command to update a bunch of documents
I am using mongodb-native driver for Node.js:
champion_statistics.bulkWrite([
{updateOne: {filter: {id: 1}, update: {$inc: {sum: 2}}, upsert: false}},
{updateOne: {filter: {id: 2}, update: {$inc: {sum: 5}}, upsert: false}}
], {
ordered: false
}, function(err, res){
//done
});
However, when I do a read, I find the collection in a state where the first operation finished but not the second operation. Is there something I can do to make multiple updates atomic?
Aucun commentaire:
Enregistrer un commentaire