Skip to content

Instantly share code, notes, and snippets.

@jcblw
Created August 3, 2019 07:57
Show Gist options
  • Save jcblw/9ea92db02d63e4f35de9b3a3cce02ecb to your computer and use it in GitHub Desktop.
Save jcblw/9ea92db02d63e4f35de9b3a3cce02ecb to your computer and use it in GitHub Desktop.
A script you can paste in your console to logout all values in an indexDB table
// See bottom to see input variables
(async function(w, d, v, t, c) {
const s = "font-size:18px;";
const h = `color:#F06E1D;${s}`;
const getRows = () => {
return new Promise(resolve => {
const r = [];
w.indexedDB.open(d, v).onsuccess = event => {
event.target.result
.transaction(t)
.objectStore(t)
.openCursor().onsuccess = event => {
var cursor = event.target.result;
if (cursor) {
r.push(cursor.value);
cursor.continue();
} else {
resolve(r);
}
};
};
});
};
let r;
try {
r = await getRows();
} catch (e) {
c.error(e);
}
rows = r;
c.log(`%c DB "${d}" Table "${t}"`, s);
c.log("%c content added to rows variable", s);
c.log('%c to copy data to your clipboard run %ccopy(rows)', s, h);
c.log({ rows });
copy(rows);
})(window, DB_NAME, DB_VERSION, TABLE_NAME, console);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment