Class IDB

Hierarchy

  • IDB

Implements

Constructors

  • Create database and return its wrapper

    Parameters

    • name: string

      Database name

    • version: number

      Database version

    • objectStores: StoreDefinition[]

      Object stores that will create and update with database version change

    • options: IDBOptions = {}

      Options for IDB object

    Returns IDB

Properties

db: IDBDatabase

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

Accessors

  • get closedDueToVersionChange(): undefined | boolean
  • Flag to check is connection to database was closed due to versionchange event

    Returns undefined | boolean

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: 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>

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

    Returns Promise<UnregisterListener>

  • Type Parameters

    • T

    • K

    Parameters

    Returns Promise<UnregisterListener>

  • Type Parameters

    • T

    Parameters

    Returns Promise<UnregisterListener>

  • Receive item from store by default store key

    Type Parameters

    • T

    • K

    Parameters

    • store: string

      Name of database store

    • keys: K

      Key value to access item in the store

    Returns Promise<void | T>

  • Type Parameters

    • T

    • K

    Parameters

    • store: string
    • keys: K[]

    Returns Promise<(void | T)[]>

  • Type Parameters

    • T

    • K

    Parameters

    • store: string
    • keys: K | K[]

    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

    • keys: K

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

    Returns Promise<boolean>

  • Type Parameters

    • K

    Parameters

    • store: string
    • keys: K[]

    Returns Promise<boolean[]>

  • Type Parameters

    • K

    Parameters

    • store: string
    • keys: K | K[]

    Returns Promise<boolean | boolean[]>

  • Parameters

    • store: string

    Returns Promise<number>

  • 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

      Serializable object that IDB can store

    Returns Promise<boolean>

  • Type Parameters

    • T

    Parameters

    • store: string
    • items: T[]

    Returns Promise<boolean[]>

  • Type Parameters

    • T

    Parameters

    • store: string
    • items: T | T[]

    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

      Key value to access item in the store

    • updateCallbacks: UpdateCallback<T>

      Async function that receives item and can directly modify them

    Returns Promise<T>

  • Type Parameters

    • T

    • K

    Parameters

    Returns Promise<T[]>

  • Type Parameters

    • T

    • K

    Parameters

    Returns Promise<T | T[]>

Generated using TypeDoc