Created
January 15, 2021 11:24
-
-
Save trojanh/7e4a203be12da9c76aa08d23147bc2f5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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