From the course: MongoDB Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Transactions

Transactions

- [Instructor] In MongoDB, an operation on a single document is atomic. If person A issues a command to change some values in a document and person B issues a command to read the same document, there are two things that can happen. Either the read will happen before the document has changed or the read will happen after the document is changed. You will not receive the document with partial changes. However, if person A issues a command to change values in multiple documents and person B tries to read the same documents at the same time, person B could see some documents that have changes already and some that do not. If this is problematic for your application, then you need transactions. Transactions guarantee atomicity of reads and writes to multiple documents. That means a read within a transaction returns all documents as they were when the read began. For writes in a transaction, that means that either all writes…

Contents