Skip to content

v2.0.0

Choose a tag to compare

@github-actions github-actions released this 29 Sep 12:42
· 3 commits to main since this release
Immutable release. Only release title and notes can be modified.
cc6cf64

doxor.js 2.0 is stable. Typed collections for IndexedDB: declare once, get types, indexes and migrations. About 4.4 kB, zero dependencies.

npm i doxor.js
import { collection, createDB } from 'doxor.js'

const db = createDB({
  name: 'app',
  collections: {
    users: collection<User>().key('id', { autoIncrement: true }).index('email', { unique: true }).index('age'),
  },
})

const id = await db.users.insert({ name: 'Ali', email: 'ali@example.com', age: 30 })
const adults = await db.users.where('age').gte(18).limit(20).toArray()

Highlights

  • Typed from one declaration: records, keys, index names and query values.
  • Automatic schema upgrades: new collections and indexes need no version bumps. Numbered migrations run once and roll back on failure.
  • Queries: ranges, startsWith, anyOf, reverse, offset, limit, filter, count, keys, delete.
  • Transactions: atomic across collections, and they detect an await on non-IndexedDB work.
  • Real errors: DoxorError with stable codes instead of silent failures.
  • Multiple tabs: tabs never block each other's upgrades, and outdated tabs are told so.
  • Everywhere: SSR-safe, ESM, TypeScript. Tested on Chromium, Firefox and WebKit, and published with npm trusted publishing and provenance.

Upgrading from 1.x

2.0 replaces the 1.x callback API. See Migrating from 1.x. Databases created by 1.x keep working when you declare the same shape. 1.x is deprecated and unmaintained.

Links

Playground · README · CHANGELOG · Roadmap issues

Thanks to @MostafaSaadatnia and @arshamalh for their earlier contributions.

Full changelog: v1.0.0-beta-1...v2.0.0