Class IDBInterfaceAbstract

Hierarchy

  • IDBInterface

Implemented by

Constructors

Properties

closedDueToVersionChange: boolean | void

Flag to check is connection to database was closed due to versionchange event

db: IDBDatabase

Access to raw database connection object. Use this for close database via yourDbVariable.db.close()

Methods

  • Delete item from store by store default key

    Type Parameters

    • K

    Parameters

    • store: string

      Name of database store

    • keys: K | K[]

      Key value to access item in the store

    Returns Promise<void>

  • Delete all items from the store

    Parameters

    • store: string

      Name of database store

    Returns Promise<void>

  • Set a listener that follow updates happened only with the selected items in store

    Example

    // Follow one item:
    db.followDataUpdates<ItemType, number>('store', 123, callback)

    Example

    // Follow multiple items, if no keys array - follow all changes in store:
    db.followDataUpdates<ItemType, number>('store', [123, 124], callback)

    Example

    // Explicit follow all changes in store:
    db.followDataUpdates<ItemType>('store', { getAll: true }, callback)

    Type Parameters

    • T

    • K

    Parameters

    • store: string

      Name of database store

    • keys: void | K | K[]

      Key of item to follow / array of item keys to follow, if no - fallback to all store items / explicit { getAll: true } to follow all changes in store

    • listener: UpdatedDataListener<void | T | (void | T)[]>

      Async function that calls every time when updates happened with selected items

    Returns Promise<UnregisterListener>

  • Receive item from store by default store key

    Type Parameters

    • T

    • K

    Parameters

    • store: string

      Name of database store

    • keys: K | K[]

      Key value to access item in the store

    Returns Promise<void | T | (void | T)[]>

  • Receive all items from the store

    Type Parameters

    • T

    Parameters

    • store: string

      Name of database store

    • Optional onData: DataReceivingCallback<T>

      Sync function that calls every time when next item received

    Returns Promise<T[]>

  • Check for item with key exist or return how much items are in the store if no keys argument

    Type Parameters

    • K

    Parameters

    • store: string

      Name of database store

    • Optional keys: K | K[]

      Key value to access item in store, if no key - return items amount in the store

    Returns Promise<number | boolean | boolean[]>

  • Add or rewrite item in the store

    Example

    {title: 'Book', author: 'Bob', data: new ArrayBuffer(32), pages: 12}
    

    Type Parameters

    • T

    Parameters

    • store: string

      Name of database store

    • items: T | T[]

      Serializable object that IDB can store

    Returns Promise<boolean | boolean[]>

  • Convenient method for get, modify and set back item to the store

    Type Parameters

    • T

    • K

    Parameters

    • store: string

      Name of database store

    • keys: K | K[]

      Key value to access item in the store

    • updateCallbacks: UpdateCallback<T> | UpdateCallback<T>[]

      Async function that receives item and can directly modify them

    Returns Promise<T | T[]>

Generated using TypeDoc