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.fixUse 'each' or 'eachBatch' instead.
affects: >=0.4.0
gotchaWhen no 'limit' option is provided, batches are fetched serially (one after another).fixProvide a 'limit' if parallel batch fetching is desired.
affects: >=0.4.0
gotchaThe 'batchSize' option is mandatory; omitting it will cause a runtime error.fixAlways 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.fixEnsure 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.
fixPass a positive integer as batchSize, e.g., new DexieBatch({ batchSize: 25 }). Error: eachKey is not implemented
Calling the non-existent 'eachKey' method.
fixUse 'each' or 'eachBatch' instead.
TypeError: collection.toCollection is not a function
Passing a Table instance instead of a Collection to the batch methods.
fixCall 'toCollection()' on the table first, e.g., db.friends.toCollection()
Audit
Dependencies
dexierequiredPeer dependency; DexieBatch requires Dexie.js (v >1.3.6) to interact with IndexedDB tables and collections.