1

is there any way to list all existing Databases? I create some dynamical for a WebApp project and think it is possible, that i will lost the names, if a user closes the Browser at a "critical" point. To be specific: When the database is already created, but i haven´t stored it´s name). Additionaly thinking about security reasons and manipulations possible.

Option 2 would be a simple "delete all databases" function.

Is there anyway to do this?

Greets & Thanks!

erik
  • 57
  • 7
  • Possible duplicate of [IndexedDB view all Databases and Object Stores](https://stackoverflow.com/questions/15234363/indexeddb-view-all-databases-and-object-stores) – milan Jun 20 '18 at 09:17

1 Answers1

1

In Chrome you can do

indexedDB.webkitGetDatabaseNames().onsuccess = function (e) {
    console.log(e.target.result);
};

But that is not part of the spec, and it won't work in other browsers. So if you want to support other browsers, you'll need to keep track of the names of your databases.

There's also no simple "delete all databases" function.

dumbmatter
  • 9,351
  • 7
  • 41
  • 80
  • Doubtful, although there are some kind-of-SQL-like things built on top of IndexedDB like https://github.com/google/lovefield – dumbmatter Mar 07 '16 at 13:49
  • 2
    webkitGetDatabaseNames is deprecated fyi: https://www.chromestatus.com/features/5725741740195840 – Nick Searle Sep 25 '17 at 18:30
  • It is possible to get list of all databases as of chrome 72. https://stackoverflow.com/a/55195418/7059164 has clear way to get it. Hope it helps people who are new and still looking for an answer. – mdsadiq Mar 16 '19 at 09:53