Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trojanh/7e4a203be12da9c76aa08d23147bc2f5 to your computer and use it in GitHub Desktop.
Save trojanh/7e4a203be12da9c76aa08d23147bc2f5 to your computer and use it in GitHub Desktop.
//https://docs.mongodb.com/v3.2/reference/method/db.collection.bulkWrite
db.enemies.bulkWrite(
[
{ updateMany :
{
"filter" : { "rating" : { $gte : 3} },
"update" : { $inc : { "encounter" : 0.1 } }
},
},
{ updateMany :
{
"filter" : { "rating" : { $lt : 2} },
"update" : { $inc : { "encounter" : -0.25 } }
},
},
{ deleteMany : { "filter" : { "encounter": { $lt : 0 } } } },
{ insertOne :
{
"document" :
{
"_id" :5, "char" : "ogrekin" , "rating" : 2, "encounter" : 0.31
}
}
}
],
{ writeConcern : { w : "majority", wtimeout : 100 } }
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment