Last active
January 6, 2023 11:38
-
-
Save dfahlander/6c1980a0b934f3d16c97c0835fa6113b to your computer and use it in GitHub Desktop.
Export-IndexedDB-using-devtools-console
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
// On any web page that stores things in IndexedDB, | |
// open devtools and in the console, write the following: | |
script1 = document.createElement('script'); | |
script1.src = 'https://unpkg.com/dexie@3.2.2'; | |
document.body.appendChild(script1); | |
script2 = document.createElement('script'); | |
script2.src = 'https://unpkg.com/dexie-export-import@1.0.3'; | |
document.body.appendChild(script2); |
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
// In devtools "applications" tab navigate to IndexedDB and find | |
// the name of the databases to export. Then write: | |
theDBName = 'the name of the database you want to export'; |
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
// Export the database into a Blob: | |
theDB = new Dexie(theDBName); | |
let {verno, tables} = await theDB.open(); | |
theDB.close(); | |
theDB = new Dexie(theDBName); | |
theDB.version(verno).stores(tables.reduce((p,c) => {p[c.name] = c.schema.primKey.keyPath || ""; return p;}, {})); | |
theBlob = await theDB.export(); |
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
// The final step - show a download link to download the blob: | |
document.body.innerHTML = ` <a href="${URL.createObjectURL(theBlob)}">Right-click to download database export</a>`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try using dynamic imports. Just modify the db name at the start.