/modern-idb

Primary LanguageTypeScriptMIT LicenseMIT

Modern-IDB

Modern IndexedDB wrapper with Promises, AsyncIterables and strict typing.

Motivation

IndexedDB API was available in browsers 3 years before Promises. Current event-based API is verbose and not as convenient to use in modern codebases as async/await.

Changes

  1. IDBRequest<T> has .then() method (except for IDBRequest<IDBCursor | IDBCursorWithValue>).
  2. IDBTransaction<T> has then() method.
  3. .openCursor() and .openKeyCursor() implement Symbol.asyncIterator.
  4. openDatabase() has a generic to specify DB schema.
  5. Validate type to validate your DB schema.
  6. Automatic versioning and DB migrations with migrations argument of openDatabase().