Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IndexedDB view all Databases and Object Stores

Tags:

I'm using IndexedDB in a Windows 8 app and I'm very new to both. I've been able to successfully create, read, update, delete objects from object stores, and have created a couple databases and a few object stores. My question is how can I list all of my object stores and databases? I create a few bogus ones that are not needed and I would like to clean things up a bit, but I can't remember what they are named. Maybe this is anal retentive, but it seems like it should be possible to list all databases and stores. Thanks!

like image 327
skinneejoe Avatar asked Mar 05 '13 21:03

skinneejoe


People also ask

How do I get all data from IndexedDB?

Using cursors # Another way to retrieve all of the data is to use a cursor. A cursor selects each object in an object store or index one by one, letting you do something with the data as it is selected. Cursors, like the other database operations, work within transactions.

Is IndexedDB deprecated?

The W3C has announced that the Web SQL database is a deprecated local storage specification so web developer should not use this technology any more. indexeddb is an alternative for web SQL data base and more effective than older technologies.

Where is IndexedDB data stored?

More specifically, IndexedDB data is stored in the browser profile folder.


2 Answers

At the time of writing this post [chrome 72], You can list all the databases using following command in console of the browser. Essentially indexedDB.databases() is a Promise. You can use it to get list of all databases as an array. Run a loop on the array to get the names of databases.

indexedDB.databases().then(r => console.log(r)) 

Hope this helps

like image 115
mdsadiq Avatar answered Nov 13 '22 17:11

mdsadiq


EDIT 2018 This answer is no longer applicable:

webkitGetDatabaseNames() is deprecated in chrome 60


In Chrome webkit there was a function which would return all database names, this function is no longer available as of Chrome 60 (webkitgetdatabasenames):

indexedDB.webkitGetDatabaseNames().onsuccess = function(sender,args) { console.log(sender.target.result); }; 

And there is another function which list all object stores in a single database which work in all browsers:

indexedDB.open(databaseName).onsuccess = function(sender, args)  { console.log(sender.target.result.objectStoreNames); }; 
like image 30
Deni Spasovski Avatar answered Nov 13 '22 18:11

Deni Spasovski