-
-
Save zewt/0ef5e39c535c3ab7abbd6b855dab9a92 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<body> | |
<script src="https://unpkg.com/dexie@4.0.4/dist/dexie.js"></script> | |
<script src="https://unpkg.com/dexie-export-import@4.1.1/dist/dexie-export-import.js"></script> | |
<script type=module> | |
var db = new Dexie("ExportBlobExampleDatabase"); | |
db.version(1).stores({ | |
example: "++id,data" | |
}); | |
let data1 = new Blob(["1234"]); | |
let data2 = new Blob(["abcd"]); | |
if(await db.example.count() == 0) | |
{ | |
await db.example.add({data: data1}); | |
await db.example.add({data: data2}); | |
} | |
let blob = await DexieExportImport.exportDB(db); | |
let a = document.createElement('a'); | |
let url = URL.createObjectURL(blob); | |
a.href = url; | |
a.download = 'test.json'; | |
a.click(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment