The getPrevError command is a command which allowed callers to do several writes with getLastError and offers the ability to read the last error which occurred and how many commands back it was. getLastError refers to result of the last write where getPreviousError refers to last error that happened.
Example:
db.foo.insert({_id:1}) WriteResult({ "nInserted" : 1 }) db.foo.insert({_id:1}) WriteResult({ "nInserted" : 0, "writeError" : { "code" : 11000, "errmsg" : "insertDocument :: caused by :: 11000 E11000 duplicate key error index: test.foo.$_id_ dup key: { : 1.0 }" } }) db.foo.insert({_id:2}) WriteResult({ "nInserted" : 1 }) db.foo.insert({_id:3}) WriteResult({ "nInserted" : 1 }) db.foo.insert({_id:4}) WriteResult({ "nInserted" : 1 }) db.getLastError() null // last write did not have an error db.getPrevError() { "err" : "insertDocument :: caused by :: 11000 E11000 duplicate key error index: test.foo.$_id_ dup key: { : 1.0 }", "code" : 11000, "n" : 1, "nPrev" : 4, // last error was four commands ago "ok" : 1 }
This functionality is not used by any MongoDB driver and with the availability of write commands and OP_MSG is not necessary as well, so we should remove it.
- is depended on by
-
DRIVERS-599 Fix test failures caused by removal of `getPrevError`
- Closed
- related to
-
PYTHON-1719 Fix test failures caused by removal of `getPrevError`
- Closed