doxor.jsTyped collections for IndexedDB
Declare your collections once. doxor infers the types, creates the indexes and upgrades the database for you.
npm i doxor.jsDeclare your collections once. doxor infers the types, creates the indexes and upgrades the database for you.
npm i doxor.js
Describe each collection with its key and indexes. Everything after that is typed: what you insert, the keys you get back, the indexes you can query and the records a query returns.
import { collection, createDB } from 'doxor.js'
type User = { id: number; name: string; email: string; age: number }
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()collection<User>(). A typo in a collection or index name is a compile error.DoxorError that has a stable code.doxor sits between raw IndexedDB and a full client-side database. If you only store a few values by key, idb-keyval is smaller. If you need live queries or sync between devices, Dexie.js does more. If you want thin promises over the raw API, idb is the closest to the metal. See the full comparison.