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

IDBPDatabase

interface IDBPDatabase <DBTypes extends DBSchema | unknown = unknown> extends IDBPDatabaseExtends {
readonly objectStoreNames: TypedDOMStringList<StoreNames<DBTypes>>;
add<Name extends StoreNames<DBTypes>>(
storeName: Name,
value: StoreValue<DBTypes, Name>,
key?: StoreKey<DBTypes, Name> | IDBKeyRange,
): Promise<StoreKey<DBTypes, Name>>;
clear(name: StoreNames<DBTypes>): Promise<void>;
count<Name extends StoreNames<DBTypes>>(storeName: Name, key?: StoreKey<DBTypes, Name> | IDBKeyRange | null): Promise<number>;
countFromIndex<Name extends StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, Name>>(
storeName: Name,
indexName: IndexName,
key?: IndexKey<DBTypes, Name, IndexName> | IDBKeyRange | null,
): Promise<number>;
createObjectStore<Name extends StoreNames<DBTypes>>(name: Name, optionalParameters?: IDBObjectStoreParameters): IDBPObjectStore<DBTypes, ArrayLike<StoreNames<DBTypes>>, Name, "versionchange">;
delete<Name extends StoreNames<DBTypes>>(storeName: Name, key: StoreKey<DBTypes, Name> | IDBKeyRange): Promise<void>;
deleteObjectStore(name: StoreNames<DBTypes>): void;
get<Name extends StoreNames<DBTypes>>(storeName: Name, query: StoreKey<DBTypes, Name> | IDBKeyRange): Promise<StoreValue<DBTypes, Name> | undefined>;
getAll<Name extends StoreNames<DBTypes>>(
storeName: Name,
query?: StoreKey<DBTypes, Name> | IDBKeyRange | null,
count?: number,
): Promise<StoreValue<DBTypes, Name>[]>;
getAllFromIndex<Name extends StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, Name>>(
storeName: Name,
indexName: IndexName,
query?: IndexKey<DBTypes, Name, IndexName> | IDBKeyRange | null,
count?: number,
): Promise<StoreValue<DBTypes, Name>[]>;
getAllKeys<Name extends StoreNames<DBTypes>>(
storeName: Name,
query?: StoreKey<DBTypes, Name> | IDBKeyRange | null,
count?: number,
): Promise<StoreKey<DBTypes, Name>[]>;
getAllKeysFromIndex<Name extends StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, Name>>(
storeName: Name,
indexName: IndexName,
query?: IndexKey<DBTypes, Name, IndexName> | IDBKeyRange | null,
count?: number,
): Promise<StoreKey<DBTypes, Name>[]>;
getFromIndex<Name extends StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, Name>>(
storeName: Name,
indexName: IndexName,
query: IndexKey<DBTypes, Name, IndexName> | IDBKeyRange,
): Promise<StoreValue<DBTypes, Name> | undefined>;
getKey<Name extends StoreNames<DBTypes>>(storeName: Name, query: StoreKey<DBTypes, Name> | IDBKeyRange): Promise<StoreKey<DBTypes, Name> | undefined>;
getKeyFromIndex<Name extends StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, Name>>(
storeName: Name,
indexName: IndexName,
query: IndexKey<DBTypes, Name, IndexName> | IDBKeyRange,
): Promise<StoreKey<DBTypes, Name> | undefined>;
put<Name extends StoreNames<DBTypes>>(
storeName: Name,
value: StoreValue<DBTypes, Name>,
key?: StoreKey<DBTypes, Name> | IDBKeyRange,
): Promise<StoreKey<DBTypes, Name>>;
transaction<Name extends StoreNames<DBTypes>, Mode extends IDBTransactionMode = "readonly">(
storeNames: Name,
mode?: Mode,
options?: IDBTransactionOptions,
): IDBPTransaction<DBTypes, [Name], Mode>;
transaction<Names extends ArrayLike<StoreNames<DBTypes>>, Mode extends IDBTransactionMode = "readonly">(
storeNames: Names,
mode?: Mode,
options?: IDBTransactionOptions,
): IDBPTransaction<DBTypes, Names, Mode>;
}

§Type Parameters

§
DBTypes extends DBSchema | unknown = unknown
[src]

§Extends

§
IDBPDatabaseExtends
[src]

§Properties

§
readonly objectStoreNames: TypedDOMStringList<StoreNames<DBTypes>>
[src]

The names of stores in the database.

§Methods

§
add<Name extends StoreNames<DBTypes>>(
storeName: Name,
value: StoreValue<DBTypes, Name>,
key?: StoreKey<DBTypes, Name> | IDBKeyRange,
): Promise<StoreKey<DBTypes, Name>>
[src]

Add a value to a store.

Rejects if an item of a given key already exists in the store.

This is a shortcut that creates a transaction for this single action. If you need to do more than one action, create a transaction instead.

@param storeName

Name of the store.

@param value
@param key
§
clear(name: StoreNames<DBTypes>): Promise<void>
[src]

Deletes all records in a store.

This is a shortcut that creates a transaction for this single action. If you need to do more than one action, create a transaction instead.

@param storeName

Name of the store.

§
count<Name extends StoreNames<DBTypes>>(storeName: Name, key?: StoreKey<DBTypes, Name> | IDBKeyRange | null): Promise<number>
[src]

Retrieves the number of records matching the given query in a store.

This is a shortcut that creates a transaction for this single action. If you need to do more than one action, create a transaction instead.

@param storeName

Name of the store.

@param key
§
countFromIndex<Name extends StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, Name>>(
storeName: Name,
indexName: IndexName,
key?: IndexKey<DBTypes, Name, IndexName> | IDBKeyRange | null,
): Promise<number>
[src]

Retrieves the number of records matching the given query in an index.

This is a shortcut that creates a transaction for this single action. If you need to do more than one action, create a transaction instead.

@param storeName

Name of the store.

@param indexName

Name of the index within the store.

@param key
§
createObjectStore<Name extends StoreNames<DBTypes>>(name: Name, optionalParameters?: IDBObjectStoreParameters): IDBPObjectStore<DBTypes, ArrayLike<StoreNames<DBTypes>>, Name, "versionchange">
[src]

Creates a new object store.

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

§
delete<Name extends StoreNames<DBTypes>>(storeName: Name, key: StoreKey<DBTypes, Name> | IDBKeyRange): Promise<void>
[src]

Deletes records in a store matching the given query.

This is a shortcut that creates a transaction for this single action. If you need to do more than one action, create a transaction instead.

@param storeName

Name of the store.

@param key
§
deleteObjectStore(name: StoreNames<DBTypes>): void
[src]

Deletes the object store with the given name.

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

§
get<Name extends StoreNames<DBTypes>>(storeName: Name, query: StoreKey<DBTypes, Name> | IDBKeyRange): Promise<StoreValue<DBTypes, Name> | undefined>
[src]

Retrieves the value of the first record in a store matching the query.

Resolves with undefined if no match is found.

This is a shortcut that creates a transaction for this single action. If you need to do more than one action, create a transaction instead.

@param storeName

Name of the store.

@param query
§
getAll<Name extends StoreNames<DBTypes>>(
storeName: Name,
query?: StoreKey<DBTypes, Name> | IDBKeyRange | null,
count?: number,
): Promise<StoreValue<DBTypes, Name>[]>
[src]

Retrieves all values in a store that match the query.

This is a shortcut that creates a transaction for this single action. If you need to do more than one action, create a transaction instead.

@param storeName

Name of the store.

@param query
@param count

Maximum number of values to return.

§
getAllFromIndex<Name extends StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, Name>>(
storeName: Name,
indexName: IndexName,
query?: IndexKey<DBTypes, Name, IndexName> | IDBKeyRange | null,
count?: number,
): Promise<StoreValue<DBTypes, Name>[]>
[src]

Retrieves all values in an index that match the query.

This is a shortcut that creates a transaction for this single action. If you need to do more than one action, create a transaction instead.

@param storeName

Name of the store.

@param indexName

Name of the index within the store.

@param query
@param count

Maximum number of values to return.

§
getAllKeys<Name extends StoreNames<DBTypes>>(
storeName: Name,
query?: StoreKey<DBTypes, Name> | IDBKeyRange | null,
count?: number,
): Promise<StoreKey<DBTypes, Name>[]>
[src]

Retrieves the keys of records in a store matching the query.

This is a shortcut that creates a transaction for this single action. If you need to do more than one action, create a transaction instead.

@param storeName

Name of the store.

@param query
@param count

Maximum number of keys to return.

§
getAllKeysFromIndex<Name extends StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, Name>>(
storeName: Name,
indexName: IndexName,
query?: IndexKey<DBTypes, Name, IndexName> | IDBKeyRange | null,
count?: number,
): Promise<StoreKey<DBTypes, Name>[]>
[src]

Retrieves the keys of records in an index matching the query.

This is a shortcut that creates a transaction for this single action. If you need to do more than one action, create a transaction instead.

@param storeName

Name of the store.

@param indexName

Name of the index within the store.

@param query
@param count

Maximum number of keys to return.

§
getFromIndex<Name extends StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, Name>>(
storeName: Name,
indexName: IndexName,
query: IndexKey<DBTypes, Name, IndexName> | IDBKeyRange,
): Promise<StoreValue<DBTypes, Name> | undefined>
[src]

Retrieves the value of the first record in an index matching the query.

Resolves with undefined if no match is found.

This is a shortcut that creates a transaction for this single action. If you need to do more than one action, create a transaction instead.

@param storeName

Name of the store.

@param indexName

Name of the index within the store.

@param query
§
getKey<Name extends StoreNames<DBTypes>>(storeName: Name, query: StoreKey<DBTypes, Name> | IDBKeyRange): Promise<StoreKey<DBTypes, Name> | undefined>
[src]

Retrieves the key of the first record in a store that matches the query.

Resolves with undefined if no match is found.

This is a shortcut that creates a transaction for this single action. If you need to do more than one action, create a transaction instead.

@param storeName

Name of the store.

@param query
§
getKeyFromIndex<Name extends StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, Name>>(
storeName: Name,
indexName: IndexName,
query: IndexKey<DBTypes, Name, IndexName> | IDBKeyRange,
): Promise<StoreKey<DBTypes, Name> | undefined>
[src]

Retrieves the key of the first record in an index that matches the query.

Resolves with undefined if no match is found.

This is a shortcut that creates a transaction for this single action. If you need to do more than one action, create a transaction instead.

@param storeName

Name of the store.

@param indexName

Name of the index within the store.

@param query
§
put<Name extends StoreNames<DBTypes>>(
storeName: Name,
value: StoreValue<DBTypes, Name>,
key?: StoreKey<DBTypes, Name> | IDBKeyRange,
): Promise<StoreKey<DBTypes, Name>>
[src]

Put an item in the database.

Replaces any item with the same key.

This is a shortcut that creates a transaction for this single action. If you need to do more than one action, create a transaction instead.

@param storeName

Name of the store.

@param value
@param key
§
transaction<Name extends StoreNames<DBTypes>, Mode extends IDBTransactionMode = "readonly">(
storeNames: Name,
mode?: Mode,
options?: IDBTransactionOptions,
): IDBPTransaction<DBTypes, [Name], Mode>
[src]

Start a new transaction.

@param storeNames

The object store(s) this transaction needs.

@param mode
@param options
§
transaction<Names extends ArrayLike<StoreNames<DBTypes>>, Mode extends IDBTransactionMode = "readonly">(
storeNames: Names,
mode?: Mode,
options?: IDBTransactionOptions,
): IDBPTransaction<DBTypes, Names, Mode>
[src]