files/en-us/web/api/idbdatabase/deleteobjectstore/index.md
{{ APIRef("IndexedDB") }} {{AvailableInWorkers}}
The deleteObjectStore() method of the
{{domxref("IDBDatabase")}} interface destroys the object store with the given name in
the connected database, along with any indexes that reference it.
As with {{ domxref("IDBDatabase.createObjectStore") }}, this method can be called
only within a versionchange
transaction.
deleteObjectStore(name)
name
None ({{jsxref("undefined")}}).
InvalidStateError {{domxref("DOMException")}}
versionchange transaction callback.TransactionInactiveError {{domxref("DOMException")}}
NotFoundError {{domxref("DOMException")}}
const dbName = "sampleDB";
const dbVersion = 2;
const request = indexedDB.open(dbName, dbVersion);
request.onupgradeneeded = (event) => {
const db = request.result;
if (event.oldVersion < 1) {
db.createObjectStore("store1");
}
if (event.oldVersion < 2) {
db.deleteObjectStore("store1");
db.createObjectStore("store2");
}
// etc. for version < 3, 4…
};
{{Specifications}}
{{Compat}}