Skip to content

Commit

Permalink
Allow different name with import
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasBora committed Jun 14, 2024
1 parent 795f60c commit 852e0ff
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions addons/dexie-export-import/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export interface StaticImportOptions {
chunkSizeBytes?: number; // Default: DEFAULT_KILOBYTES_PER_CHUNK ( 1MB )
filter?: (table: string, value: any, key?: any) => boolean;
progressCallback?: (progress: ImportProgress) => boolean;
name?: string;
}

export interface ImportOptions extends StaticImportOptions {
Expand Down
3 changes: 2 additions & 1 deletion addons/dexie-export-import/src/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface StaticImportOptions {
filter?: (table: string, value: any, key?: any) => boolean;
transform?: (table: string, value: any, key?: any) => ({value: any, key?: any});
progressCallback?: (progress: ImportProgress) => boolean;
name?: string;
}

export interface ImportOptions extends StaticImportOptions {
Expand Down Expand Up @@ -42,7 +43,7 @@ export async function importDB(exportedData: Blob | JsonStream<DexieExportJsonSt
const CHUNK_SIZE = options!.chunkSizeBytes || (DEFAULT_KILOBYTES_PER_CHUNK * 1024);
const stream = await loadUntilWeGotEnoughData(exportedData, CHUNK_SIZE);
const dbExport = stream.result.data!;
const db = new Dexie(dbExport.databaseName);
const db = new Dexie(options.name !== undefined ? options.name : dbExport.databaseName);
db.version(dbExport.databaseVersion).stores(extractDbSchema(dbExport));
await importInto(db, stream, options);
return db;
Expand Down

0 comments on commit 852e0ff

Please sign in to comment.