Details
-
Improvement
-
Status: Closed
-
Major - P3
-
Resolution: Won't Fix
-
3.2.0
-
None
-
Server Tooling & Methods
Description
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 }
|
Attachments
Issue Links
- is related to
-
DOCS-6898 findAndModify takes a write concern
-
- Closed
-