Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试在 ReactiveMongo中包含该$setOnInsert字段。但是,我似乎无法让它与内置命令一起使用。UpdateFindAndModify
$setOnInsert
Update
FindAndModify
有谁知道如何包含此字段以更新文档?
这个简单的例子对我有用:
val collection = ... // your collection goes here collection.update( obj("_id" -> "1"), obj( "$setOnInsert" -> obj("field 1" -> "value 1"), "$set" -> obj("field 2" -> "value 2")), upsert = true ).map { case n => println(n.ok.toString) // do smth }