What do you mean by Transactions?

For relational databases, transactions ensure data integrity. These are set of instructions that satisfies the conditions of the ACID (atomic, consistent, isolated, and durable) property test. For example, it may require to complete all SQL statements in one go, on failure the entire update can be rolled back.

In MongoDB, an operation on a single document is atomic. Because you can use embedded documents and arrays to capture relationships between data in a single document structure instead of normalizing across multiple documents and collections, this single-document atomicity obviates the need for multi-document transactions for many practical use cases.

For situations that require atomicity of reads and writes to multiple documents (in a single or multiple collections), MongoDB supports multi-document transactions. With distributed transactions, transactions can be used across multiple operations, collections, databases, documents, and shards.

The new callback API works with transactions, which starts a transaction, executes the specified operations, and commits (or aborts on error). The new callback API also incorporates retry logic for TransientTransactionError or UnknownTransactionCommitResult commit errors.


Transactions — MongoDB Manual. mongodb.com/docs/manual/core/transactions.