01 / 10

What Are Transactions in MongoDB?

Transactions in MongoDB allow you to perform multiple operations across one or more documents (and collections) as a single, atomic unit. This means that all the operations in a transaction are either fully completed (committed) or fully undone (rolled back) if an error occurs.

Key Features of Transactions:
  1. 1

    Atomicity: Ensures that all operations within a transaction are applied as a single unit.

  2. 2

    Consistency: Maintains data consistency by ensuring that changes made during a transaction do not leave the database in an inconsistent state.

  3. 3

    Isolation: Guarantees that ongoing transactions do not interfere with each other