KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Is there a way to check if an IndexedDB database already exists? When a program tries to open a database that does not exists the database is created. The only way that I can think of is something like the following, where I test if an objectStore already exists, if it doesn't, the database is deleted: var dbexists=false; var request = window.indexedDB.open("TestDatabase"); request.onupgradeneeded = function(e) { db = e.target.result; if (!db.objectStoreNames.contains('todo')) { db.close(); indexedDB.deleteDatabase("TestDatabase"); } else { dbexists=true; } }
Tags (comma-separated)
Save Edits
Cancel