0Pricing
JavaScript Academy · Lesson

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

  1. Opening a Database
  2. Transactions and CRUD
  3. Indexes and Queries
  4. Versioning and Upgrades
← Back to JavaScript Academy