On this page
getLastError( <w> , <wtimeout> )
Changed in version 2.6: A new protocol for write operations integrates write concerns with the write operations, eliminating the need for a separate db.getLastError(). Most write methods now return the status of the write operation, including error information. In previous versions, clients typically used the db.getLastError() in combination with a write operation to verify that the write succeeded.
The db.getLastError() can accept the following parameters:
|int or string||Optional. The write concern’s |
|int||Optional. The time limit in milliseconds.|
The returned error string provides error information on the previous write operation.
The following example issues a db.getLastError() operation that verifies that the preceding write operation, issued over the same connection, has propagated to at least two members of the replica set.