Transactions and CRUD
Add, read, update, and delete records.
Everything Is a Transaction
In IndexedDB, all reads and writes happen inside a transaction. A transaction groups operations so they either all succeed or all roll back, keeping data consistent.
Starting a Transaction
Create one with db.transaction(storeNames, mode). The mode is 'readonly' (default) or 'readwrite' for modifications.
const tx = db.transaction('notes', 'readwrite');
const store = tx.objectStore('notes');All lessons in this course
- Opening a Database
- Transactions and CRUD
- Indexes and Queries
- Versioning and Upgrades