OPTIONS

db.getLastError()

db.getLastError()

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() method. Write methods now return the status of the write operation, including error information.

In previous versions, clients typically used the db.getLastError() method in combination with the write operations to ensure that the write succeeds.

Returns:The last error message string.

Sets the level of write concern for confirming the success of write operations.

See

getLastError and Write Concern Reference for all options, Write Concern for a conceptual overview, Write Operations for information about all write operations in MongoDB.

ON THIS PAGE