Skip to content

Commit

Permalink
Allow setting chunk size per table
Browse files Browse the repository at this point in the history
  • Loading branch information
lvivski committed Feb 28, 2024
1 parent 6a2810b commit 39bd9fb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/classes/collection/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,15 @@ export class Collection implements ICollection {

const coreTable = ctx.table.core;
const {outbound, extractKey} = coreTable.schema.primaryKey;
const limit = this.db._options.modifyChunkSize || 200;
let limit = 200;
const modifyChunkSize = this.db._options.modifyChunkSize;
if (modifyChunkSize) {
if (typeof modifyChunkSize == 'object') {
limit = modifyChunkSize[coreTable.name] || modifyChunkSize['*'] || 200;
} else {
limit = modifyChunkSize;
}
}
const totalFailures = [];
let successCount = 0;
const failedKeys: IndexableType[] = [];
Expand Down
2 changes: 1 addition & 1 deletion src/public/types/dexie-constructor.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface DexieOptions {
indexedDB?: {open: Function};
IDBKeyRange?: {bound: Function, lowerBound: Function, upperBound: Function};
allowEmptyDB?: boolean;
modifyChunkSize?: number;
modifyChunkSize?: number | { [key: string]: number };
chromeTransactionDurability?: ChromeTransactionDurability;
cache?: 'immutable' | 'cloned' | 'disabled';
}
Expand Down

0 comments on commit 39bd9fb

Please sign in to comment.