-
Type:
Improvement
-
Resolution: Won't Fix
-
Priority:
Major - P3
-
None
-
Affects Version/s: 3.2.0
-
Component/s: JavaScript, Shell
-
Server Tooling & Methods
-
None
-
None
-
None
-
None
-
None
-
None
-
None
When using the shell helper db.collection.findAndModify(), you cannot determine if a write concern error has occurred. You can only do so via the dbcommand version of findAndModify:
replset:PRIMARY> db.products.find()
{ "_id" : ObjectId("568eb38f3a04b65e35ff642c"), "sku" : 1, "field" : 9 }
replset:PRIMARY> db.runCommand( { findAndModify: "products", query: { sku: 1 }, update: { $inc: { field: 1 } }, writeConcern: { w: 3, wtimeout: 5000 } } )
{
"lastErrorObject" : {
"updatedExisting" : true,
"n" : 1
},
"value" : {
"_id" : ObjectId("568eb38f3a04b65e35ff642c"),
"sku" : 1,
"field" : 9
},
"writeConcernError" : {
"code" : 64,
"errmsg" : "waiting for replication timed out"
},
"ok" : 1
}
replset:PRIMARY> db.products.findAndModify( { query: { sku: 1 }, update: { $inc: { field: 1 } }, writeConcern: { w: 3, wtimeout: 5000 } } )
{ "_id" : ObjectId("568eb38f3a04b65e35ff642c"), "sku" : 1, "field" : 10 }