JavaScript AcademyProfessional Engineering

Learning object 49 of 100

IndexedDB data explorer

Open a sample database, add and query records with stores, transactions and indexes, and watch each request's result.

Loading…

What it shows

IndexedDB is an asynchronous database in the browser. A database has object stores with a key (keyPath or autoIncrement) and optional indexes. Structure is created in onupgradeneeded, every read and write happens in a transaction (readwrite must be requested), and each operation is a request with success and error events. In this sandboxed preview a memory-only stand-in with the same API runs the programs, because a sandboxed frame cannot use the browser's real IndexedDB; downloaded files use the real one.

Guided experiment

  1. In Add and read, add a third note and run again.
  2. In Index query, query the classic genre instead.
  3. In Modes, remove "readwrite" and read the error.

Predict

What is the default transaction mode?

Related

Lessons: Lesson 70: IndexedDB fundamentals

Projects: Project 9: Shopping Cart Price Calculator

Source: web/assets/js/objects/object-049.js in the companion repository.