Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026
The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.
Deleting the database, an object store and data
Delete an entire IndexedDB database
//first import deleteDb from `idb`
import { deleteDB } from 'idb'
//or
import { deleteDB } from 'https://cdn.jsdelivr.net/npm/idb@7/+esm'
//then:
const dbName = 'mydbname'
await deleteDB(dbName)
To delete data in an object store
We use a transaction:
(async () => {
//...
const dbName = 'mydbname'
const storeName = 'store1'
const version = 1
const db = await openDB(dbName, version, {
upgrade(db, oldVersion, newVersion, transaction) {
const store = db.createObjectStore(storeName)
}
})
const tx = await db.transaction(storeName, 'readwrite')
const store = await tx.objectStore(storeName)
const key = 'Hello again'
await store.delete(key)
await tx.done
})() Lessons in this unit:
| 0: | Introduction |
| 1: | Loading the idb library |
| 2: | Creating a database and a store |
| 3: | Adding data into a store |
| 4: | Retrieving data from a store |
| 5: | ▶︎ Deleting data |
| 6: | Migrations |
| 7: | Unique keys |