Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Upgrade<DBSchema>

A wrapper for the opening database and transaction during an upgrade.

An instance of this is created when Database.open is called with a schema version number that has never been opened in that environment before. Use it to upgrade the schema from the old version to the new version. Stores and indexes can only be created during an upgrade, so some care is advised.

Type parameters

Hierarchy

  • Upgrade

Index

Properties

Optional newVersion

newVersion: undefined | number

The schema version after this upgrade.

oldVersion

oldVersion: number

The schema version before this upgrade.

Methods

createStore

  • createStore<Name>(storeName: Name): Store<DBSchema, StoreNames<DBSchema>[], Name>
  • Create a store in the database.

    Stores can only be created during an upgrade, so this is the opportunity to do so.

    Type parameters

    Parameters

    • storeName: Name

    Returns Store<DBSchema, StoreNames<DBSchema>[], Name>

transaction

  • transaction(storeNames: StoreNames<DBSchema>[], tx: (stores: StoreMap<DBSchema, StoreNames<DBSchema>[]>) => void | Promise<void>): Promise<void>
  • Add operations to the transaction created by this upgrade event.

    Parameters

    • storeNames: StoreNames<DBSchema>[]

      The stores to open the transaction over.

    • tx: (stores: StoreMap<DBSchema, StoreNames<DBSchema>[]>) => void | Promise<void>

      A callback for the transaction to call. Be aware that this callback, although possibly asynchronous, needs to be updating the transaction every tick. If no changes to the transaction happen in a tick, it will automatically commit itself and the transaction will close.

    Returns Promise<void>

Generated using TypeDoc