idb
- Version 8.0.2
- Published
- 82.3 kB
- No dependencies
- ISC license
Install
npm i idb
yarn add idb
pnpm add idb
Overview
A small wrapper that makes IndexedDB usable
Index
Variables
Functions
Interfaces
Type Aliases
Variables
variable unwrap
const unwrap: Unwrap;
Functions
function deleteDB
deleteDB: (name: string, { blocked }?: DeleteDBCallbacks) => Promise<void>;
Delete a database.
Parameter name
Name of the database.
function openDB
openDB: <DBTypes extends unknown = unknown>( name: string, version?: number, { blocked, upgrade, blocking, terminated }?: OpenDBCallbacks<DBTypes>) => Promise<IDBPDatabase<DBTypes>>;
Open a database.
Parameter name
Name of the database.
Parameter version
Schema version.
Parameter callbacks
Additional callbacks.
function wrap
wrap: { (value: IDBDatabase): IDBPDatabase; (value: IDBIndex): IDBPIndex< unknown, ArrayLike<string>, string, string, 'readonly' >; (value: IDBObjectStore): IDBPObjectStore< unknown, ArrayLike<string>, string, 'readonly' >; (value: IDBTransaction): IDBPTransaction<unknown, ArrayLike<string>, 'readonly'>; (value: IDBOpenDBRequest): Promise<IDBPDatabase<unknown>>; <T>(value: IDBRequest<T>): Promise<T>;};
Enhance an IDB object with helpers.
Parameter value
The thing to enhance.
Interfaces
interface DBSchema
interface DBSchema {}
index signature
[s: string]: DBSchemaValue;
interface DeleteDBCallbacks
interface DeleteDBCallbacks {}
method blocked
blocked: (currentVersion: number, event: IDBVersionChangeEvent) => void;
Called if there are connections to this database open, so it cannot be deleted.
Parameter currentVersion
Version of the database that's blocking the delete operation.
Parameter event
The event object for the associated
blocked
event.
interface IDBPCursor
interface IDBPCursor< DBTypes extends DBSchema | unknown = unknown, TxStores extends ArrayLike<StoreNames<DBTypes>> = ArrayLike<StoreNames<DBTypes>>, StoreName extends StoreNames<DBTypes> = StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, StoreName> | unknown = unknown, Mode extends IDBTransactionMode = 'readonly'> extends IDBPCursorExtends {}
property delete
delete: Mode extends 'readonly' ? undefined : () => Promise<void>;
Delete the current record.
property key
readonly key: CursorKey<DBTypes, StoreName, IndexName>;
The key of the current index or object store item.
property primaryKey
readonly primaryKey: StoreKey<DBTypes, StoreName>;
The key of the current object store item.
property source
readonly source: CursorSource<DBTypes, TxStores, StoreName, IndexName, Mode>;
Returns the IDBObjectStore or IDBIndex the cursor was opened from.
property update
update: Mode extends 'readonly' ? undefined : ( value: StoreValue<DBTypes, StoreName> ) => Promise<StoreKey<DBTypes, StoreName>>;
Updated the current record.
method [Symbol.asyncIterator]
[Symbol.asyncIterator]: () => AsyncIterableIterator< IDBPCursorIteratorValue<DBTypes, TxStores, StoreName, IndexName, Mode>>;
Iterate over the cursor.
method advance
advance: <T>(this: T, count: number) => Promise<T | null>;
Advances the cursor a given number of records.
Resolves to null if no matching records remain.
method continue
continue: <T>( this: T, key?: CursorKey<DBTypes, StoreName, IndexName>) => Promise<T | null>;
Advance the cursor by one record (unless 'key' is provided).
Resolves to null if no matching records remain.
Parameter key
Advance to the index or object store with a key equal to or greater than this value.
method continuePrimaryKey
continuePrimaryKey: <T>( this: T, key: CursorKey<DBTypes, StoreName, IndexName>, primaryKey: StoreKey<DBTypes, StoreName>) => Promise<T | null>;
Advance the cursor by given keys.
The operation is 'and' – both keys must be satisfied.
Resolves to null if no matching records remain.
Parameter key
Advance to the index or object store with a key equal to or greater than this value.
Parameter primaryKey
and where the object store has a key equal to or greater than this value.
interface IDBPCursorIteratorValue
interface IDBPCursorIteratorValue< DBTypes extends DBSchema | unknown = unknown, TxStores extends ArrayLike<StoreNames<DBTypes>> = ArrayLike<StoreNames<DBTypes>>, StoreName extends StoreNames<DBTypes> = StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, StoreName> | unknown = unknown, Mode extends IDBTransactionMode = 'readonly'> extends IDBPCursorIteratorValueExtends< DBTypes, TxStores, StoreName, IndexName, Mode > {}
method advance
advance: <T>(this: T, count: number) => void;
Advances the cursor a given number of records.
method continue
continue: <T>(this: T, key?: CursorKey<DBTypes, StoreName, IndexName>) => void;
Advance the cursor by one record (unless 'key' is provided).
Parameter key
Advance to the index or object store with a key equal to or greater than this value.
method continuePrimaryKey
continuePrimaryKey: <T>( this: T, key: CursorKey<DBTypes, StoreName, IndexName>, primaryKey: StoreKey<DBTypes, StoreName>) => void;
Advance the cursor by given keys.
The operation is 'and' – both keys must be satisfied.
Parameter key
Advance to the index or object store with a key equal to or greater than this value.
Parameter primaryKey
and where the object store has a key equal to or greater than this value.
interface IDBPCursorWithValue
interface IDBPCursorWithValue< DBTypes extends DBSchema | unknown = unknown, TxStores extends ArrayLike<StoreNames<DBTypes>> = ArrayLike<StoreNames<DBTypes>>, StoreName extends StoreNames<DBTypes> = StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, StoreName> | unknown = unknown, Mode extends IDBTransactionMode = 'readonly'> extends IDBPCursor<DBTypes, TxStores, StoreName, IndexName, Mode> {}
property value
readonly value: StoreValue<DBTypes, StoreName>;
The value of the current item.
method [Symbol.asyncIterator]
[Symbol.asyncIterator]: () => AsyncIterableIterator< IDBPCursorWithValueIteratorValue< DBTypes, TxStores, StoreName, IndexName, Mode >>;
Iterate over the cursor.
interface IDBPCursorWithValueIteratorValue
interface IDBPCursorWithValueIteratorValue< DBTypes extends DBSchema | unknown = unknown, TxStores extends ArrayLike<StoreNames<DBTypes>> = ArrayLike<StoreNames<DBTypes>>, StoreName extends StoreNames<DBTypes> = StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, StoreName> | unknown = unknown, Mode extends IDBTransactionMode = 'readonly'> extends IDBPCursorWithValueIteratorValueExtends< DBTypes, TxStores, StoreName, IndexName, Mode > {}
method advance
advance: <T>(this: T, count: number) => void;
Advances the cursor a given number of records.
method continue
continue: <T>(this: T, key?: CursorKey<DBTypes, StoreName, IndexName>) => void;
Advance the cursor by one record (unless 'key' is provided).
Parameter key
Advance to the index or object store with a key equal to or greater than this value.
method continuePrimaryKey
continuePrimaryKey: <T>( this: T, key: CursorKey<DBTypes, StoreName, IndexName>, primaryKey: StoreKey<DBTypes, StoreName>) => void;
Advance the cursor by given keys.
The operation is 'and' – both keys must be satisfied.
Parameter key
Advance to the index or object store with a key equal to or greater than this value.
Parameter primaryKey
and where the object store has a key equal to or greater than this value.
interface IDBPDatabase
interface IDBPDatabase<DBTypes extends DBSchema | unknown = unknown> extends IDBPDatabaseExtends {}
property objectStoreNames
readonly objectStoreNames: TypedDOMStringList<StoreNames<DBTypes>>;
The names of stores in the database.
method add
add: <Name extends StoreNames<DBTypes>>( storeName: Name, value: StoreValue<DBTypes, Name>, key?: StoreKey<DBTypes, Name> | IDBKeyRange) => Promise<StoreKey<DBTypes, Name>>;
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.
Parameter storeName
Name of the store.
Parameter value
Parameter key
method clear
clear: (name: StoreNames<DBTypes>) => Promise<void>;
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.
Parameter storeName
Name of the store.
method count
count: <Name extends StoreNames<DBTypes>>( storeName: Name, key?: StoreKey<DBTypes, Name> | IDBKeyRange | null) => Promise<number>;
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.
Parameter storeName
Name of the store.
Parameter key
method countFromIndex
countFromIndex: < Name extends StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, Name>>( storeName: Name, indexName: IndexName, key?: IndexKey<DBTypes, Name, IndexName> | IDBKeyRange | null) => Promise<number>;
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.
Parameter storeName
Name of the store.
Parameter indexName
Name of the index within the store.
Parameter key
method createObjectStore
createObjectStore: <Name extends StoreNames<DBTypes>>( name: Name, optionalParameters?: IDBObjectStoreParameters) => IDBPObjectStore< DBTypes, ArrayLike<StoreNames<DBTypes>>, Name, 'versionchange'>;
Creates a new object store.
Throws a "InvalidStateError" DOMException if not called within an upgrade transaction.
method delete
delete: <Name extends StoreNames<DBTypes>>( storeName: Name, key: StoreKey<DBTypes, Name> | IDBKeyRange) => Promise<void>;
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.
Parameter storeName
Name of the store.
Parameter key
method deleteObjectStore
deleteObjectStore: (name: StoreNames<DBTypes>) => void;
Deletes the object store with the given name.
Throws a "InvalidStateError" DOMException if not called within an upgrade transaction.
method get
get: <Name extends StoreNames<DBTypes>>( storeName: Name, query: StoreKey<DBTypes, Name> | IDBKeyRange) => Promise<StoreValue<DBTypes, Name> | undefined>;
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.
Parameter storeName
Name of the store.
Parameter query
method getAll
getAll: <Name extends StoreNames<DBTypes>>( storeName: Name, query?: StoreKey<DBTypes, Name> | IDBKeyRange | null, count?: number) => Promise<StoreValue<DBTypes, Name>[]>;
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.
Parameter storeName
Name of the store.
Parameter query
Parameter count
Maximum number of values to return.
method getAllFromIndex
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>[]>;
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.
Parameter storeName
Name of the store.
Parameter indexName
Name of the index within the store.
Parameter query
Parameter count
Maximum number of values to return.
method getAllKeys
getAllKeys: <Name extends StoreNames<DBTypes>>( storeName: Name, query?: StoreKey<DBTypes, Name> | IDBKeyRange | null, count?: number) => Promise<StoreKey<DBTypes, Name>[]>;
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.
Parameter storeName
Name of the store.
Parameter query
Parameter count
Maximum number of keys to return.
method getAllKeysFromIndex
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>[]>;
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.
Parameter storeName
Name of the store.
Parameter indexName
Name of the index within the store.
Parameter query
Parameter count
Maximum number of keys to return.
method getFromIndex
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>;
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.
Parameter storeName
Name of the store.
Parameter indexName
Name of the index within the store.
Parameter query
method getKey
getKey: <Name extends StoreNames<DBTypes>>( storeName: Name, query: StoreKey<DBTypes, Name> | IDBKeyRange) => Promise<StoreKey<DBTypes, Name> | undefined>;
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.
Parameter storeName
Name of the store.
Parameter query
method getKeyFromIndex
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>;
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.
Parameter storeName
Name of the store.
Parameter indexName
Name of the index within the store.
Parameter query
method put
put: <Name extends StoreNames<DBTypes>>( storeName: Name, value: StoreValue<DBTypes, Name>, key?: StoreKey<DBTypes, Name> | IDBKeyRange) => Promise<StoreKey<DBTypes, Name>>;
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.
Parameter storeName
Name of the store.
Parameter value
Parameter key
method transaction
transaction: { < Name extends StoreNames<DBTypes>, Mode extends IDBTransactionMode = 'readonly' >( storeNames: Name, mode?: Mode, options?: IDBTransactionOptions ): IDBPTransaction<DBTypes, [Name], Mode>; < Names extends ArrayLike<StoreNames<DBTypes>>, Mode extends IDBTransactionMode = 'readonly' >( storeNames: Names, mode?: Mode, options?: IDBTransactionOptions ): IDBPTransaction<DBTypes, Names, Mode>;};
Start a new transaction.
Parameter storeNames
The object store(s) this transaction needs.
Parameter mode
Parameter options
interface IDBPIndex
interface IDBPIndex< DBTypes extends DBSchema | unknown = unknown, TxStores extends ArrayLike<StoreNames<DBTypes>> = ArrayLike<StoreNames<DBTypes>>, StoreName extends StoreNames<DBTypes> = StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, StoreName> = IndexNames< DBTypes, StoreName >, Mode extends IDBTransactionMode = 'readonly'> extends IDBPIndexExtends {}
property objectStore
readonly objectStore: IDBPObjectStore<DBTypes, TxStores, StoreName, Mode>;
The IDBObjectStore the index belongs to.
method [Symbol.asyncIterator]
[Symbol.asyncIterator]: () => AsyncIterableIterator< IDBPCursorWithValueIteratorValue< DBTypes, TxStores, StoreName, IndexName, Mode >>;
Iterate over the index.
method count
count: ( key?: IndexKey<DBTypes, StoreName, IndexName> | IDBKeyRange | null) => Promise<number>;
Retrieves the number of records matching the given query.
method get
get: ( query: IndexKey<DBTypes, StoreName, IndexName> | IDBKeyRange) => Promise<StoreValue<DBTypes, StoreName> | undefined>;
Retrieves the value of the first record matching the query.
Resolves with undefined if no match is found.
method getAll
getAll: ( query?: IndexKey<DBTypes, StoreName, IndexName> | IDBKeyRange | null, count?: number) => Promise<StoreValue<DBTypes, StoreName>[]>;
Retrieves all values that match the query.
Parameter query
Parameter count
Maximum number of values to return.
method getAllKeys
getAllKeys: ( query?: IndexKey<DBTypes, StoreName, IndexName> | IDBKeyRange | null, count?: number) => Promise<StoreKey<DBTypes, StoreName>[]>;
Retrieves the keys of records matching the query.
Parameter query
Parameter count
Maximum number of keys to return.
method getKey
getKey: ( query: IndexKey<DBTypes, StoreName, IndexName> | IDBKeyRange) => Promise<StoreKey<DBTypes, StoreName> | undefined>;
Retrieves the key of the first record that matches the query.
Resolves with undefined if no match is found.
method iterate
iterate: ( query?: IndexKey<DBTypes, StoreName, IndexName> | IDBKeyRange | null, direction?: IDBCursorDirection) => AsyncIterableIterator< IDBPCursorWithValueIteratorValue< DBTypes, TxStores, StoreName, IndexName, Mode >>;
Iterate over the records matching the query.
Resolves with null if no matches are found.
Parameter query
If null, all records match.
Parameter direction
method openCursor
openCursor: ( query?: IndexKey<DBTypes, StoreName, IndexName> | IDBKeyRange | null, direction?: IDBCursorDirection) => Promise<IDBPCursorWithValue< DBTypes, TxStores, StoreName, IndexName, Mode> | null>;
Opens a cursor over the records matching the query.
Resolves with null if no matches are found.
Parameter query
If null, all records match.
Parameter direction
method openKeyCursor
openKeyCursor: ( query?: IndexKey<DBTypes, StoreName, IndexName> | IDBKeyRange | null, direction?: IDBCursorDirection) => Promise<IDBPCursor<DBTypes, TxStores, StoreName, IndexName, Mode> | null>;
Opens a cursor over the keys matching the query.
Resolves with null if no matches are found.
Parameter query
If null, all records match.
Parameter direction
interface IDBPObjectStore
interface IDBPObjectStore< DBTypes extends DBSchema | unknown = unknown, TxStores extends ArrayLike<StoreNames<DBTypes>> = ArrayLike<StoreNames<DBTypes>>, StoreName extends StoreNames<DBTypes> = StoreNames<DBTypes>, Mode extends IDBTransactionMode = 'readonly'> extends IDBPObjectStoreExtends {}
property add
add: Mode extends 'readonly' ? undefined : ( value: StoreValue<DBTypes, StoreName>, key?: StoreKey<DBTypes, StoreName> | IDBKeyRange ) => Promise<StoreKey<DBTypes, StoreName>>;
Add a value to the store.
Rejects if an item of a given key already exists in the store.
property clear
clear: Mode extends 'readonly' ? undefined : () => Promise<void>;
Deletes all records in store.
property createIndex
createIndex: Mode extends 'versionchange' ? <IndexName extends IndexNames<DBTypes, StoreName>>( name: IndexName, keyPath: string | string[], options?: IDBIndexParameters ) => IDBPIndex<DBTypes, TxStores, StoreName, IndexName, Mode> : undefined;
Creates a new index in store.
Throws an "InvalidStateError" DOMException if not called within an upgrade transaction.
property delete
delete: Mode extends 'readonly' ? undefined : (key: StoreKey<DBTypes, StoreName> | IDBKeyRange) => Promise<void>;
Deletes records in store matching the given query.
property indexNames
readonly indexNames: TypedDOMStringList<IndexNames<DBTypes, StoreName>>;
The names of indexes in the store.
property put
put: Mode extends 'readonly' ? undefined : ( value: StoreValue<DBTypes, StoreName>, key?: StoreKey<DBTypes, StoreName> | IDBKeyRange ) => Promise<StoreKey<DBTypes, StoreName>>;
Put an item in the store.
Replaces any item with the same key.
property transaction
readonly transaction: IDBPTransaction<DBTypes, TxStores, Mode>;
The associated transaction.
method [Symbol.asyncIterator]
[Symbol.asyncIterator]: () => AsyncIterableIterator< IDBPCursorWithValueIteratorValue<DBTypes, TxStores, StoreName, unknown, Mode>>;
Iterate over the store.
method count
count: ( key?: StoreKey<DBTypes, StoreName> | IDBKeyRange | null) => Promise<number>;
Retrieves the number of records matching the given query.
method get
get: ( query: StoreKey<DBTypes, StoreName> | IDBKeyRange) => Promise<StoreValue<DBTypes, StoreName> | undefined>;
Retrieves the value of the first record matching the query.
Resolves with undefined if no match is found.
method getAll
getAll: ( query?: StoreKey<DBTypes, StoreName> | IDBKeyRange | null, count?: number) => Promise<StoreValue<DBTypes, StoreName>[]>;
Retrieves all values that match the query.
Parameter query
Parameter count
Maximum number of values to return.
method getAllKeys
getAllKeys: ( query?: StoreKey<DBTypes, StoreName> | IDBKeyRange | null, count?: number) => Promise<StoreKey<DBTypes, StoreName>[]>;
Retrieves the keys of records matching the query.
Parameter query
Parameter count
Maximum number of keys to return.
method getKey
getKey: ( query: StoreKey<DBTypes, StoreName> | IDBKeyRange) => Promise<StoreKey<DBTypes, StoreName> | undefined>;
Retrieves the key of the first record that matches the query.
Resolves with undefined if no match is found.
method index
index: <IndexName extends IndexNames<DBTypes, StoreName>>( name: IndexName) => IDBPIndex<DBTypes, TxStores, StoreName, IndexName, Mode>;
Get a query of a given name.
method iterate
iterate: ( query?: StoreKey<DBTypes, StoreName> | IDBKeyRange | null, direction?: IDBCursorDirection) => AsyncIterableIterator< IDBPCursorWithValueIteratorValue<DBTypes, TxStores, StoreName, unknown, Mode>>;
Iterate over the records matching the query.
Parameter query
If null, all records match.
Parameter direction
method openCursor
openCursor: ( query?: StoreKey<DBTypes, StoreName> | IDBKeyRange | null, direction?: IDBCursorDirection) => Promise<IDBPCursorWithValue< DBTypes, TxStores, StoreName, unknown, Mode> | null>;
Opens a cursor over the records matching the query.
Resolves with null if no matches are found.
Parameter query
If null, all records match.
Parameter direction
method openKeyCursor
openKeyCursor: ( query?: StoreKey<DBTypes, StoreName> | IDBKeyRange | null, direction?: IDBCursorDirection) => Promise<IDBPCursor<DBTypes, TxStores, StoreName, unknown, Mode> | null>;
Opens a cursor over the keys matching the query.
Resolves with null if no matches are found.
Parameter query
If null, all records match.
Parameter direction
interface IDBPTransaction
interface IDBPTransaction< DBTypes extends DBSchema | unknown = unknown, TxStores extends ArrayLike<StoreNames<DBTypes>> = ArrayLike<StoreNames<DBTypes>>, Mode extends IDBTransactionMode = 'readonly'> extends IDBPTransactionExtends {}
property db
readonly db: IDBPDatabase<DBTypes>;
The transaction's connection.
property done
readonly done: Promise<void>;
Promise for the completion of this transaction.
property mode
readonly mode: Mode;
The transaction's mode.
property objectStoreNames
readonly objectStoreNames: TypedDOMStringList<TxStores[number]>;
The names of stores in scope for this transaction.
property store
readonly store: TxStores[1] extends undefined ? IDBPObjectStore<DBTypes, TxStores, TxStores[0], Mode> : undefined;
The associated object store, if the transaction covers a single store, otherwise undefined.
method objectStore
objectStore: <StoreName extends TxStores[number]>( name: StoreName) => IDBPObjectStore<DBTypes, TxStores, StoreName, Mode>;
Returns an IDBObjectStore in the transaction's scope.
interface OpenDBCallbacks
interface OpenDBCallbacks<DBTypes extends DBSchema | unknown> {}
method blocked
blocked: ( currentVersion: number, blockedVersion: number | null, event: IDBVersionChangeEvent) => void;
Called if there are older versions of the database open on the origin, so this version cannot open.
Parameter currentVersion
Version of the database that's blocking this one.
Parameter blockedVersion
The version of the database being blocked (whatever version you provided to
openDB
).Parameter event
The event object for the associated
blocked
event.
method blocking
blocking: ( currentVersion: number, blockedVersion: number | null, event: IDBVersionChangeEvent) => void;
Called if this connection is blocking a future version of the database from opening.
Parameter currentVersion
Version of the open database (whatever version you provided to
openDB
).Parameter blockedVersion
The version of the database that's being blocked.
Parameter event
The event object for the associated
versionchange
event.
method terminated
terminated: () => void;
Called if the browser abnormally terminates the connection. This is not called when
db.close()
is called.
method upgrade
upgrade: ( database: IDBPDatabase<DBTypes>, oldVersion: number, newVersion: number | null, transaction: IDBPTransaction< DBTypes, StoreNames<DBTypes>[], 'versionchange' >, event: IDBVersionChangeEvent) => void;
Called if this version of the database has never been opened before. Use it to specify the schema for the database.
Parameter database
A database instance that you can use to add/remove stores and indexes.
Parameter oldVersion
Last version of the database opened by the user.
Parameter newVersion
Whatever new version you provided.
Parameter transaction
The transaction for this upgrade. This is useful if you need to get data from other stores as part of a migration.
Parameter event
The event object for the associated 'upgradeneeded' event.
interface TypedDOMStringList
interface TypedDOMStringList<T extends string> extends DOMStringList {}
A variation of DOMStringList with precise string types
method [Symbol.iterator]
[Symbol.iterator]: () => IterableIterator<T>;
method contains
contains: (string: T) => boolean;
method item
item: (index: number) => T | null;
index signature
[index: number]: T;
Type Aliases
type IndexKey
type IndexKey< DBTypes extends DBSchema | unknown, StoreName extends StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, StoreName>> = DBTypes extends DBSchema ? IndexName extends keyof DBTypes[StoreName]['indexes'] ? DBTypes[StoreName]['indexes'][IndexName] : IDBValidKey : IDBValidKey;
Extract the types of indexes in certain object stores from the DB schema type.
DBTypes DB schema type, or unknown if the DB isn't typed. StoreName Names of the object stores to get the types of. IndexName Names of the indexes to get the types of.
type IndexNames
type IndexNames< DBTypes extends DBSchema | unknown, StoreName extends StoreNames<DBTypes>> = DBTypes extends DBSchema ? keyof DBTypes[StoreName]['indexes'] & string : string;
Extract the names of indexes in certain object stores from the DB schema type.
DBTypes DB schema type, or unknown if the DB isn't typed. StoreName Names of the object stores to get the types of.
type StoreKey
type StoreKey< DBTypes extends DBSchema | unknown, StoreName extends StoreNames<DBTypes>> = DBTypes extends DBSchema ? DBTypes[StoreName]['key'] : IDBValidKey;
Extract database key types from the DB schema type.
DBTypes DB schema type, or unknown if the DB isn't typed. StoreName Names of the object stores to get the types of.
type StoreNames
type StoreNames<DBTypes extends DBSchema | unknown> = DBTypes extends DBSchema ? KnownKeys<DBTypes> : string;
Extract known object store names from the DB schema type.
DBTypes DB schema type, or unknown if the DB isn't typed.
type StoreValue
type StoreValue< DBTypes extends DBSchema | unknown, StoreName extends StoreNames<DBTypes>> = DBTypes extends DBSchema ? DBTypes[StoreName]['value'] : any;
Extract database value types from the DB schema type.
DBTypes DB schema type, or unknown if the DB isn't typed. StoreName Names of the object stores to get the types of.
Package Files (3)
Dependencies (0)
No dependencies.
Dev Dependencies (16)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/idb
.
- Markdown[](https://www.jsdocs.io/package/idb)
- HTML<a href="https://www.jsdocs.io/package/idb"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 4822 ms. - Missing or incorrect documentation? Open an issue for this package.