Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

IDBDatabase

import { IDBDatabase } from "https://raw.githubusercontent.com/aaronhuggins/indexeddb/main/ponyfill.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.

interface IDBDatabase extends EventTarget {
readonly name: string;
readonly objectStoreNames: DOMStringList;
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;
prototype: IDBDatabase;
readonly version: number;
addEventListener<K extends keyof IDBDatabaseEventMap>(
type: K,
listener: (this: IDBDatabase, ev: IDBDatabaseEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void;
addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): void;
close(): void;
createObjectStore(name: string, options?: IDBObjectStoreParameters): IDBObjectStore;
deleteObjectStore(name: string): void;
new (): IDBDatabase;
removeEventListener<K extends keyof IDBDatabaseEventMap>(
type: K,
listener: (this: IDBDatabase, ev: IDBDatabaseEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): void;
removeEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): void;
transaction(storeNames: string | string[], mode?: IDBTransactionMode): IDBTransaction;
}
const IDBDatabase;

§Extends

§
EventTarget
[src]

§Properties

§
readonly name: string
[src]

Returns the name of the database.

§
readonly objectStoreNames: DOMStringList
[src]

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

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

Returns the version of the database.

§Methods

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

Closes the connection once all running transactions have finished.

§
createObjectStore(name: string, options?: IDBObjectStoreParameters): IDBObjectStore
[src]

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
[src]

Deletes the object store with the given name.

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

§
removeEventListener<K extends keyof IDBDatabaseEventMap>(
type: K,
listener: (this: IDBDatabase, ev: IDBDatabaseEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): void
[src]
§
removeEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): void
[src]
§
transaction(storeNames: string | string[], mode?: IDBTransactionMode): IDBTransaction
[src]

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.