Skip to main content
Module

x/evt/mod.ts>dom.IDBDatabase

💧EventEmitter's typesafe replacement
Go to Latest
interface dom.IDBDatabase
implements EventTarget
import { type dom } from "https://deno.land/x/evt@v2.3.1/mod.ts";
const { IDBDatabase } = dom;

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.

Methods

close(): void

Closes the connection once all running transactions have finished.

createObjectStore(name: string, optionalParameters?: 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