Answer Posted / Asit Kumar
In MongoDB, you can use multi-document transactions for maintaining data consistency across multiple documents. This feature is available since MongoDB version 3.6. To perform a transaction, wrap your operations inside a try block and catch exceptions for any errors that might occur. You should use the 'beginTransaction', 'getCommitTimestamp' or 'startSession' methods to start a session, and 'commitTransaction' or 'endSession' to commit changes. For locking, MongoDB uses MVCC (Multi-Version Concurrency Control) which allows multiple operations to work concurrently without causing conflicts.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers