Skip to content

Commit

Permalink
Allow setting chunk size per table (#1909)
Browse files Browse the repository at this point in the history
  • Loading branch information
lvivski authored Nov 15, 2024
1 parent 7781374 commit 9f604e0
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 @@ -491,7 +491,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 9f604e0

Please sign in to comment.