// This script is adapted from david fahlander's post: https://dfahlander.medium.com/export-indexeddb-from-a-web-app-using-devtools-62c55a8996a1
// You should be able to drop this in the console on a riverside.fm page once you're logged in.
// Find the indexdb table name that you want to import by 2. Include dexie-export-import into the page.
const dbName = 'export-db'
const loadScript = src =>
new Promise(resolve => {
let script = document.createElement('script')
script.src = src;
script.onload = resolve;
document.body.appendChild(script);
})
await loadScript('https://unpkg.com/dexie');
await loadScript('https://unpkg.com/dexie-export-import');
let db = new Dexie(dbName);
const { verno, tables } await db.open();
db.close();
db = new Dexie(dbName);
db.version(verno).stores(tables.reduce((p,c) => {
p[c.name] = c.schema.primKey.keyPath || "";
return p;
}, {}));
const blob = await db.export({
numRowsPerChunk: 2 // This is important because riverside's rows can be 4mb and dexie's default is 2k rows which will absolutely crash the browser
});
document.body.innerHTML = `
<a href=’${URL.createObjectURL(blob)}’>Right-click to download database export</a>
`