This example shows a variety of different uses of object stores, from updating the data structure with IDBObjectStore.createIndex inside an onupgradeneeded function, to adding a new item to our object store with IDBObjectStore.add. For a full working example, see our To-do Notifications app (view example live.)

Hierarchy

  • IDBObjectStore

Properties

autoIncrement: boolean

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

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

keyPath: string | string[]

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

name: string

Returns the name of the store.

Returns the associated transaction.

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.

    Parameters

    Returns <internal>.IDBRequest<IDBValidKey>

  • Deletes all records in store.

    If successful, request's result will be undefined.

    Returns <internal>.IDBRequest<undefined>

  • 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.

    Parameters

    Returns <internal>.IDBIndex

  • Deletes the index in store with the given name.

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

    Parameters

    • name: string

    Returns void

  • 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.

    Parameters

    Returns <internal>.IDBRequest<IDBValidKey>

Generated using TypeDoc