The deleteDatabase()
method of the IDBFactory
interface requests the deletion of a database. The method returns an IDBOpenDBRequest
object immediately, and performs the deletion operation asynchronously.
If the database is successfully deleted, then a success
event is fired on the request object returned from this method, with its result
set to undefined
. If an error occurs while the database is being deleted, then an error
event is fired on the request object that is returned from this method.
Will trigger an upgradedneeded
event and, if any other tabs have open connections to the database, a blocked
event.
For the current standard:
var request = window.indexedDB.deleteDatabase("toDoList");
For the experimental version with options
(see below):
var request = window.indexedDB.deleteDatabase("toDoList", { storage: "temporary" });
permanent
(the default value) IndexedDB, or an indexedDB in temporary
storage (aka shared pool.)A IDBOpenDBRequest
on which subsequent events related to this request are fired.
var DBDeleteRequest = window.indexedDB.deleteDatabase("toDoList"); DBDeleteRequest.onerror = function(event) { console.log("Error deleting database."); }; DBDeleteRequest.onsuccess = function(event) { console.log("Database deleted successfully"); console.log(event.result); // should be undefined };
Specification | Status | Comment |
---|---|---|
Indexed Database API The definition of 'deleteDatabase' in that specification. | Recommendation |
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support | 23webkit 24 (unprefixed) | (Yes) | 10 moz 16.0 (16.0) | 10, partial | 15 | 7.1 |
Available in workers | (Yes) | (Yes) | 37.0 (37.0) | ? | (Yes) | ? |
Feature | Android | Android Webview | Edge | Firefox Mobile (Gecko) | Firefox OS | IE Phone | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|---|---|
Basic support | 4.4 | (Yes) | (Yes) | 22.0 (22.0) | 1.0.1 | 10 | 22 | 8 | (Yes) |
Available in workers | (Yes) | (Yes) | (Yes) | 37.0 (37.0) | (Yes) | ? | (Yes) | ? | (Yes) |
IDBDatabase
IDBTransaction
IDBKeyRange
IDBObjectStore
IDBCursor
© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/IDBFactory/deleteDatabase