Continuing on from SERVER-10771, it would also be nice if applyOps could continue on error, while returning details about the errors it encountered.
For example in ....
backup_test:PRIMARY> db.fruit.ensureIndex({name:1},{unique:true}) backup_test:PRIMARY> db.fruit.insert({name: 'cherry'}) backup_test:PRIMARY> db.fruit.insert({name: 'banana'}) backup_test:PRIMARY> db.fruit.insert({name: 'pear'}) backup_test:PRIMARY> db.fruit.remove({name: 'banana'}) backup_test:PRIMARY> db.fruit.insert({name: 'banana'}) backup_test:PRIMARY> use local switched to db local backup_test:PRIMARY> var ops = []; db.oplog.rs.find().sort({$natural:-1}).limit(5).forEach( function(opDoc) {ops.push(opDoc)}); backup_test:PRIMARY> db.runCommand({applyOps: ops}) { "errmsg" : "exception: E11000 duplicate key error index: fruit.fruit.$name_1 dup key: { : \"banana\" }", "code" : 11000, "ok" : 0 }
... the server fails on the 2nd op. It would be nice to have the option to have it continue on and finish the batch, while returning an array of responses indicating whether or not each op succeeded, and error messages for any ops that failed.
- related to
-
SERVER-10771 If applyOps encounters an error, indicate which op caused the error
- Closed