What Is a Transaction?

Learn to understand transactions, their working, and life cycle in IndexedDB.

A transaction in IndexedDB is a unit of work that’s performed on a database.

IndexedDB transactions work based on a commit or rollback mechanism, which ensures that all or none of the transactions are successful. This mechanism helps to ensure the consistency, completeness, and atomicity of the data present in the database.

How do transactions work?

When we start a transaction, IndexedDB locks the database to prevent other transactions from accessing it. This ensures that the data in the database isn’t changed while the transaction is in progress. Once the transaction is complete, IndexedDB unlocks the database and ...