Skip to content

Commit

Permalink
Update dexie-export-import.md
Browse files Browse the repository at this point in the history
Highlight peelImportFile() and other API examples.
  • Loading branch information
dfahlander authored Jun 14, 2024
1 parent 6ea6f1d commit 459db1d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docs/ExportImport/dexie-export-import.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,36 @@ Here's the basic usage. There's a lot you can do by supplying optional `[options
import Dexie from "dexie";
import {importDB, exportDB, importInto, peakImportFile} from "dexie-export-import";

//
// --- importDB() ---
//
// Import from Blob or File to Dexie instance:
//
const db = await importDB(blob, [options]);

//
// --- exportDB() ---
//
// Export to Blob
//
const blob = await exportDB(db, [options]);

//
// --- importInto() ---
//
// Import from Blob or File to existing Dexie instance
//
await importInto(db, blob, [options]);

//
// --- peakImportFile() ---
//
// If you need to peek the metadata from the import file without actually
// performing any import operation
// (since v1.0.0)
//
const importMeta = await peakImportFile(blob);

assert.areEqual(importMeta.formatName, "dexie");
assert.isTrue(importMeta.formatVersion === 1);
console.log("Database name:", importMeta.data.databaseName);
Expand All @@ -61,16 +70,22 @@ Note that you can also import the package as follows:
import Dexie from "dexie";
import "dexie-export-import";

//
// --- Dexie.import() ---
//
// Import from Blob or File to Dexie instance:
//
const db = await Dexie.import(blob, [options]); // equivalent to importDB()

//
// --- db.export() ---
//
// Export to Blob
//
const blob = await db.export([options]); // equivalent to exportDB()

//
// --- db.import() ---
//
// Import from Blob or File to existing Dexie instance
//
Expand Down

0 comments on commit 459db1d

Please sign in to comment.