Skip to main content
Deno 2 is finally here 🎉️
Learn more
Latest
interface IDBDatabase
implements EventTarget
import { type IDBDatabase } from "https://deno.land/x/indexeddb@1.3.5/lib/indexeddb.ts";

This IndexedDB API interface provides a connection to a database; you can use an IDBDatabase object to open a transaction on your database then create, manipulate, and delete objects (data) in that database. The interface provides the only way to get and manage versions of the database.

Properties

readonly
name: string

Returns the name of the database.

readonly
objectStoreNames: DOMStringList

Returns a list of the names of object stores in the database.

onabort: ((this: IDBDatabase, ev: Event) => any) | null
onclose: ((this: IDBDatabase, ev: Event) => any) | null
onerror: ((this: IDBDatabase, ev: Event) => any) | null
onversionchange: ((this: IDBDatabase, ev: IDBVersionChangeEvent) => any) | null
readonly
version: number

Returns the version of the database.

prototype: IDBDatabase

Methods

close(): void

Closes the connection once all running transactions have finished.

createObjectStore(name: string, options?: IDBObjectStoreParameters): IDBObjectStore

Creates a new object store with the given name and options and returns a new IDBObjectStore.

Throws a "InvalidStateError" DOMException if not called within an upgrade transaction.

deleteObjectStore(name: string): void

Deletes the object store with the given name.

Throws a "InvalidStateError" DOMException if not called within an upgrade transaction.

transaction(storeNames: string | string[], mode?: IDBTransactionMode): IDBTransaction

Returns a new transaction with the given mode ("readonly" or "readwrite") and scope which can be a single object store name or an array of names.

addEventListener<K extends keyof IDBDatabaseEventMap>(
type: K,
listener: (this: IDBDatabase, ev: IDBDatabaseEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void
addEventListener(
type: string,
options?: boolean | AddEventListenerOptions,
): void
removeEventListener<K extends keyof IDBDatabaseEventMap>(
type: K,
listener: (this: IDBDatabase, ev: IDBDatabaseEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): void
removeEventListener(
type: string,
options?: boolean | EventListenerOptions,
): void