Interface IDBIndex

IDBIndex interface of the IndexedDB API provides asynchronous access to an index in a database. An index is a kind of object store for looking up records in another object store, called the referenced object store. You use this interface to retrieve data.

MDN Reference

interface IDBIndex {
    keyPath: string | string[];
    multiEntry: boolean;
    name: string;
    objectStore: IDBObjectStore;
    unique: boolean;
    count(query?: IDBValidKey | IDBKeyRange): IDBRequest<number>;
    get(query: IDBValidKey | IDBKeyRange): IDBRequest<any>;
    getAll(query?: null | IDBValidKey | IDBKeyRange, count?: number): IDBRequest<any[]>;
    getAllKeys(query?: null | IDBValidKey | IDBKeyRange, count?: number): IDBRequest<IDBValidKey[]>;
    getKey(query: IDBValidKey | IDBKeyRange): IDBRequest<undefined | IDBValidKey>;
    openCursor(query?: null | IDBValidKey | IDBKeyRange, direction?: IDBCursorDirection): IDBRequest<null | IDBCursorWithValue>;
    openKeyCursor(query?: null | IDBValidKey | IDBKeyRange, direction?: IDBCursorDirection): IDBRequest<null | IDBCursor>;
}

Properties

keyPath: string | string[]
multiEntry: boolean
name: string

Returns the name of the index.

MDN Reference

objectStore: IDBObjectStore

Returns the IDBObjectStore the index belongs to.

MDN Reference

unique: boolean

Methods

  • Retrieves the number of records matching the given key or key range in query.

    If successful, request's result will be the count.

    MDN Reference

    Parameters

    Returns IDBRequest<number>

  • Retrieves the value of the first record matching the given key or key range in query.

    If successful, request's result will be the value, or undefined if there was no matching record.

    MDN Reference

    Parameters

    Returns IDBRequest<any>

  • Retrieves the values of the records matching the given key or key range in query (up to count if given).

    If successful, request's result will be an Array of the values.

    MDN Reference

    Parameters

    Returns IDBRequest<any[]>

  • Retrieves the keys of records matching the given key or key range in query (up to count if given).

    If successful, request's result will be an Array of the keys.

    MDN Reference

    Parameters

    Returns IDBRequest<IDBValidKey[]>

  • Retrieves the key of the first record matching the given key or key range in query.

    If successful, request's result will be the key, or undefined if there was no matching record.

    MDN Reference

    Parameters

    Returns IDBRequest<undefined | IDBValidKey>

  • Opens a cursor with key only flag set over the records matching query, ordered by direction. If query is null, all records in index are matched.

    If successful, request's result will be an IDBCursor, or null if there were no matching records.

    MDN Reference

    Parameters

    Returns IDBRequest<null | IDBCursor>