Registry / database / dexie-batch

dexie-batch

JSON →
library0.4.3jsnpmunverified

Dexie Batch (v0.4.3) is a utility library for Dexie.js that fetches IndexedDB entries in configurable batch sizes to improve performance and avoid 'Maximum IPC message size exceeded' errors in browser environments. It provides two iteration methods: each (process individual items) and eachBatch (process batches). Batches are fetched in parallel when a limit is specified, otherwise serially. Last updated in 2021, stable release, minimal API surface with clear documentation. Differentiator: solves IPC size limits specific to Dexie/IndexedDB, not generic batch processing.

npm install dexie-batch
INSTALL
IMPORT
SIG · DEXIE-BATCH
D
dexie-batch
databasejavascriptv0.4.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.

DexieBatch
✓ import DexieBatch from 'dexie-batch'
✗ const DexieBatch = require('dexie-batch')
ESM default export; CommonJS require works but is not recommended.
DexieBatch (constructor)
✓ const batch = new DexieBatch({ batchSize: 10, limit: 100 })
✗ const batch = new DexieBatch(10, 100)
Options must be passed as an object; batchSize is required.
batch.each
✓ batch.each(collection, (item, idx) => { ... })
✗ batch.each(table, callback)
Method expects a Dexie.Collection, not a Table.
batch.eachBatch
✓ batch.eachBatch(collection, (batch, batchIdx) => { ... })
Callback receives array of items (the batch) and batch index.

Creates a Dexie database with 'friends' table, adds sample data, then fetches records in batches of 2 using DexieBatch.each.

import Dexie from 'dexie'; import DexieBatch from 'dexie-batch'; const db = new Dexie('MyDatabase'); db.version(1).stores({ friends: '++id, name, age' }); async function processFriends() { await db.friends.bulkAdd([ { name: 'Alice', age: 30 }, { name: 'Bob', age: 25 }, { name: 'Charlie', age: 35 } ]); const collection = db.friends.where('age').above(20).toCollection(); const batchDriver = new DexieBatch({ batchSize: 2, limit: 10 }); await batchDriver.each(collection, (friend, index) => { console.log(`Processing friend: ${friend.name}`); }); console.log('All done!'); } processFriends().catch(console.error);
Debug
Known issues
deprecatedThe 'eachKey' and 'eachUniqueKey' methods are not implemented and will throw if called.
fix
Use 'each' or 'eachBatch' instead.
affects: >=0.4.0
gotchaWhen no 'limit' option is provided, batches are fetched serially (one after another).
fix
Provide a 'limit' if parallel batch fetching is desired.
affects: >=0.4.0
gotchaThe 'batchSize' option is mandatory; omitting it will cause a runtime error.
fix
Always pass { batchSize: <number> } to the constructor.
affects: >=0.4.0
breakingDexie 3.x dropped built-in Promise; the 'isParallel' method may return false for valid parallel scenarios.
fix
Ensure you use Dexie.Promise polyfill or adjust limit usage; check documentation.
affects: >=0.4.0 with Dexie >=3.0
Errors
Common errors & fixes
Uncaught (in promise) Error: batchSize must be a positive integer
The 'batchSize' option was omitted or set to an invalid value.
fix
Pass a positive integer as batchSize, e.g., new DexieBatch({ batchSize: 25 }).
Error: eachKey is not implemented
Calling the non-existent 'eachKey' method.
fix
Use 'each' or 'eachBatch' instead.
TypeError: collection.toCollection is not a function
Passing a Table instance instead of a Collection to the batch methods.
fix
Call 'toCollection()' on the table first, e.g., db.friends.toCollection()
Upgrade
Version history
0.4.3latest on npm
Audit
Dependencies
dexierequiredPeer dependency; DexieBatch requires Dexie.js (v >1.3.6) to interact with IndexedDB tables and collections.
Agent activity
5 hits · last 30 days
node
4
Resources
dexie-batch — npm install dexie-batch · libregistry