IndexedDB view all Databases and Object Stores

2019-01-15 08:07发布

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!

3条回答
Animai°情兽
2楼-- · 2019-01-15 08:26

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); };
查看更多
叼着烟拽天下
3楼-- · 2019-01-15 08:30

There is currently no way of enumerating the existing databases in the standard. Windows 8 apps use IE, which does not provide the non-standard webkitGetDatabaseNames method. You might be able to clear the databases using the options dialog in IE10.

Listing the stores inside a database is defined in the standard using the objectStoreNames method of an IDBDatabase instance.

查看更多
兄弟一词,经得起流年.
4楼-- · 2019-01-15 08:32

Since all other topics reference back here as a duplicates. In Chrome you can view and delete all created databases in Developer Tools > Application > Storage.

查看更多
登录 后发表回答