scala - Is there any way to perform bulk updates on ReactiveMongo? -


suppose want following (in mongo shell):

var bulk = db.vectors.initializeorderedbulkop()  bulk.find({"_id" : objectid("53f265da13d3f885ed8bf75d")}).updateone({"$pop": {"v": 1}})  bulk.find({"_id" : objectid("53f265da13d3f885ed8bf75d")}).updateone({"$push": {"v": 5}})  bulk.execute() 

i found answer! reactivemongo has rawcommand command let run mongodb command (like update, in case >> http://docs.mongodb.org/manual/reference/command/update/#dbcmd.update):

  val commanddoc =         bsondocument(           "update" -> collection,           "updates" -> bsonarray(             bsondocument("q" -> <query>, "u" -> bsondocument("$pop" -> bsondocument("v" -> 1))),             bsondocument("q" -> <query>, "u" -> bsondocument("$push" -> bsondocument("v" -> 5)))           ),           "ordered" -> true         )        // future[bsondocument]       val futureresult = db.command(rawcommand(commanddoc))        futureresult.map { result => // result bsondocument            //...       } 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -