files/en-us/web/api/idbfactory/deletedatabase/index.md
{{APIRef("IndexedDB")}} {{AvailableInWorkers}}
The deleteDatabase() method of the
{{DOMxRef("IDBFactory")}} interface requests the deletion of a database. The method
returns an {{DOMxRef("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.
When deleteDatabase() is called, any other open connections to this
particular database will get a versionchange event.
// For the current standard:
deleteDatabase(name)
// For the experimental version with `options` (see below):
deleteDatabase(name)
deleteDatabase(name, options)
name
options {{optional_inline}} {{Non-standard_Inline}}
permanent (the default value) IndexedDB, or an indexedDB in
temporary storage (aka shared pool.)An {{DOMxRef("IDBOpenDBRequest")}} on which subsequent events related to this request are fired.
If the operation is successful, the value of the request's {{domxref("IDBRequest.result", "result")}} property is null.
const DBDeleteRequest = window.indexedDB.deleteDatabase("toDoList");
DBDeleteRequest.onerror = (event) => {
console.error("Error deleting database.");
};
DBDeleteRequest.onsuccess = (event) => {
console.log("Database deleted successfully");
console.log(event.result); // should be undefined
};
{{Specifications}}
{{Compat}}