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).fixUse 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.fixUpgrade 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.fixUse 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.fixAlways await db.connect() before any CRUD.
affects: >=4.0.0-alpha
breakingv4.0.0-alpha drops CommonJS support; package is pure ESM.fixUse 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'
fixUse named import: import { Connector } from 'indexeddb-orm' Cannot read properties of undefined (reading 'openRequest') at Connector.connect
Calling query methods before awaiting db.connect()
fixAdd '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
fixEnsure 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
fixProvide 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