Interface IDBObjectStore

    interface IDBObjectStore {
        autoIncrement: boolean;
        indexNames: DOMStringList;
        keyPath: string | string[];
        name: string;
        transaction: IDBTransaction;
        add(value: any, key?: IDBValidKey): IDBRequest<IDBValidKey>;
        clear(): IDBRequest<undefined>;
        count(query?: IDBValidKey | IDBKeyRange): IDBRequest<number>;
        createIndex(name: string, keyPath: string | string[], options?: IDBIndexParameters): IDBIndex;
        createIndex(name: string, keyPath: string | Iterable<string, any, any>, options?: IDBIndexParameters): IDBIndex;
        delete(query: IDBValidKey | IDBKeyRange): IDBRequest<undefined>;
        deleteIndex(name: string): void;
        get(query: IDBValidKey | IDBKeyRange): IDBRequest<any>;
        getAll(query?: IDBValidKey | IDBKeyRange, count?: number): IDBRequest<any[]>;
        getAllKeys(query?: IDBValidKey | IDBKeyRange, count?: number): IDBRequest<IDBValidKey[]>;
        getKey(query: IDBValidKey | IDBKeyRange): IDBRequest<IDBValidKey>;
        index(name: string): IDBIndex;
        openCursor(query?: IDBValidKey | IDBKeyRange, direction?: IDBCursorDirection): IDBRequest<IDBCursorWithValue>;
        openKeyCursor(query?: IDBValidKey | IDBKeyRange, direction?: IDBCursorDirection): IDBRequest<IDBCursor>;
        put(value: any, key?: IDBValidKey): IDBRequest<IDBValidKey>;
    }

    Properties

    autoIncrement: boolean

    Returns true if the store has a key generator, and false otherwise.

    MDN Reference

    indexNames: DOMStringList

    Returns a list of the names of indexes in the store.

    MDN Reference

    keyPath: string | string[]

    Returns the key path of the store, or null if none.

    MDN Reference

    name: string

    Returns the name of the store.

    MDN Reference

    transaction: IDBTransaction

    Returns the associated transaction.

    MDN Reference

    Methods

    • Adds or updates a record in store with the given value and key.

      If the store uses in-line keys and key is specified a "DataError" DOMException will be thrown.

      If put() is used, any existing record with the key will be replaced. If add() is used, and if a record with the key already exists the request will fail, with request's error set to a "ConstraintError" DOMException.

      If successful, request's result will be the record's key.

      MDN Reference

      Parameters

      Returns IDBRequest<IDBValidKey>

    • Creates a new index in store with the given name, keyPath and options and returns a new IDBIndex. If the keyPath and options define constraints that cannot be satisfied with the data already in store the upgrade transaction will abort with a "ConstraintError" DOMException.

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

      MDN Reference

      Parameters

      Returns IDBIndex

    • Creates a new index in store with the given name, keyPath and options and returns a new IDBIndex. If the keyPath and options define constraints that cannot be satisfied with the data already in store the upgrade transaction will abort with a "ConstraintError" DOMException.

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

      MDN Reference

      Parameters

      Returns IDBIndex

    • Deletes the index in store with the given name.

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

      MDN Reference

      Parameters

      • name: string

      Returns void

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

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

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

      MDN Reference

      Parameters

      Returns IDBRequest<IDBCursor>

    • Adds or updates a record in store with the given value and key.

      If the store uses in-line keys and key is specified a "DataError" DOMException will be thrown.

      If put() is used, any existing record with the key will be replaced. If add() is used, and if a record with the key already exists the request will fail, with request's error set to a "ConstraintError" DOMException.

      If successful, request's result will be the record's key.

      MDN Reference

      Parameters

      Returns IDBRequest<IDBValidKey>