Registry / database / indexeddb-orm

indexeddb-orm

JSON →
library4.0.0-alpha.3jsnpmunverified

A promise-based ORM wrapper for IndexedDB, providing a fluent query builder with support for model instances, relationships (hasOne, hasMany), indexing, aggregations, and transactional actions. Current stable version 2.1.0 (legacy branch) while v4.0.0-alpha.3 is under development. Key differentiator is a full ORM layer with relations and custom classes, unlike simpler wrappers like Dexie.js which focus on queries. Ships TypeScript types. Note: v4.0.0-alpha is unstable and has breaking changes from v2.1.0.

npm install indexeddb-orm
INSTALL
IMPORT
SIG · INDEXEDDB-ORM
I
indexeddb-orm
databasejavascriptv4.0.0-alpha.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Connector
import { Connector } from 'indexeddb-orm'
import Connector from 'indexeddb-orm'
Named export, not default. ESM only.
Model
import { Model } from 'indexeddb-orm'
const Model = require('indexeddb-orm').Model
ESM syntax. CommonJS not officially supported but works with bundlers.
QueryBuilder
import { QueryBuilder } from 'indexeddb-orm'
import { QueryBuilder } from 'indexeddb-orm/dist/query-builder.js'
Internal path not needed, main export re-exports it.

Connects to IndexedDB, defines a model, and inserts a record using the ORM.

import { Connector, Model } from 'indexeddb-orm'; const settings = { name: 'myDatabase', version: 1, migrations: [ { name: 'users', primary: 'id', autoIncrement: true, indexes: [{ name: 'name' }] } ] }; const db = new Connector(settings); class User extends Model { static get tableName() { return 'users'; } } const run = async () => { await db.connect(); const user = await User.create({ name: 'Alice' }); console.log(user); }; run();
Debug
Known issues
breakingv4.0.0-alpha changes import paths and API. v2.1.0 used different exports (e.g., 'idb' function).
fix
Use v2.1.0 branch for stable ORM API. For v4-alpha, follow docs at maxgaurav.github.io/indexeddb-orm.
affects: >=4.0.0-alpha.1 <4.0.0
deprecatedv2.1.0 (older version) is maintained on a separate branch but no longer actively developed.
fix
Upgrade to v4-alpha for new features, beware breaking changes.
affects: <=2.1.0
gotchaIndexedDB is not available in Node.js; package only works in browser/Web Workers.
fix
Use only in browser or Web Workers. For Node, consider using fake-indexeddb or sqlite alternatives.
affects: all
gotchaThe Connector instance must be connected before using any Model operations. Forgetting await db.connect() throws 'Database not connected' error.
fix
Always await db.connect() before any CRUD.
affects: >=4.0.0-alpha
breakingv4.0.0-alpha drops CommonJS support; package is pure ESM.
fix
Use ES import syntax; if using require(), use dynamic import or bundler.
affects: >=4.0.0-alpha.1
Errors
Common errors & fixes
Uncaught TypeError: indexeddb_orm__WEBPACK_IMPORTED_MODULE_0__.Connector is not a constructor
Default import instead of named import: import Connector from 'indexeddb-orm'
fix
Use named import: import { Connector } from 'indexeddb-orm'
Cannot read properties of undefined (reading 'openRequest') at Connector.connect
Calling query methods before awaiting db.connect()
fix
Add 'await db.connect();' before any Model operation
Uncaught (in promise) DOMException: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found.
Table name mismatch between migration definition and Model.tableName
fix
Ensure migration 'name' matches exactly with Model.tableName (case-sensitive)
Uncaught TypeError: Cannot read properties of undefined (reading 'id') at new ModelItem
Primary key field missing in data when creating without autoIncrement
fix
Provide the primary key value in the object passed to Model.create()
Upgrade
Version history
4.0.0-alpha.3latest on npm
Audit
Dependencies
indexeddboptionalbrowser IndexedDB API is required, but used directly without polyfill
Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
indexeddb-orm — npm install indexeddb-orm · libregistry