Member-only story
MongoDB Transaction
Starting from this lesson, we will learn how to use transaction. First, we need to talk about ACID.
ACID represents the four basic characters of a transaction operation. It stands for atomicity, consistency, isolation and durability.
In the content of databases, a sequence of database operations that satisfies the ACID properties is called a transaction. So one transaction usually consists of several database operations.
Transaction guarantees data validity despite errors power failures and other mishaps.
Atomicity is the most important character.
An atom is defined as the smallest individual particle of a matter. It means undividable.
Atomicity means operations of the same transaction are bound together and behave as if they were a single unit. These operations will either succeed completely or fail completely.
For the transaction to be successful, every operation must be successful. If one operation fails, no matter how insignificant it is, the whole transaction will abort and fail. In simple words, atomicity means all or nothing.