idb-keyval

  • Version 6.0.3
  • Published
  • 47 kB
  • 1 dependency
  • Apache-2.0 license

Install

npm i idb-keyval
yarn add idb-keyval
pnpm add idb-keyval

Overview

A super-simple-small keyval store built on top of IndexedDB

Index

Functions

function clear

clear: (customStore?: UseStore) => Promise<void>;
  • Clear all values in the store.

    Parameter customStore

    Method to get a custom store. Use with caution (see the docs).

function createStore

createStore: (dbName: string, storeName: string) => UseStore;

    function del

    del: (key: IDBValidKey, customStore?: UseStore) => Promise<void>;
    • Delete a particular key from the store.

      Parameter key

      Parameter customStore

      Method to get a custom store. Use with caution (see the docs).

    function delMany

    delMany: (keys: IDBValidKey[], customStore?: UseStore) => Promise<void>;
    • Delete multiple keys at once.

      Parameter keys

      List of keys to delete.

      Parameter customStore

      Method to get a custom store. Use with caution (see the docs).

    function entries

    entries: <KeyType extends IDBValidKey, ValueType = any>(
    customStore?: UseStore
    ) => Promise<[KeyType, ValueType][]>;
    • Get all entries in the store. Each entry is an array of [key, value].

      Parameter customStore

      Method to get a custom store. Use with caution (see the docs).

    function get

    get: <T = any>(
    key: IDBValidKey,
    customStore?: UseStore
    ) => Promise<T | undefined>;
    • Get a value by its key.

      Parameter key

      Parameter customStore

      Method to get a custom store. Use with caution (see the docs).

    function getMany

    getMany: <T = any>(keys: IDBValidKey[], customStore?: UseStore) => Promise<T[]>;
    • Get multiple values by their keys

      Parameter keys

      Parameter customStore

      Method to get a custom store. Use with caution (see the docs).

    function keys

    keys: <KeyType extends IDBValidKey>(
    customStore?: UseStore
    ) => Promise<KeyType[]>;
    • Get all keys in the store.

      Parameter customStore

      Method to get a custom store. Use with caution (see the docs).

    function promisifyRequest

    promisifyRequest: <T = undefined>(
    request: IDBRequest<T> | IDBTransaction
    ) => Promise<T>;

      function set

      set: (key: IDBValidKey, value: any, customStore?: UseStore) => Promise<void>;
      • Set a value with a key.

        Parameter key

        Parameter value

        Parameter customStore

        Method to get a custom store. Use with caution (see the docs).

      function setMany

      setMany: (
      entries: [IDBValidKey, any][],
      customStore?: UseStore
      ) => Promise<void>;
      • Set multiple values at once. This is faster than calling set() multiple times. It's also atomic – if one of the pairs can't be added, none will be added.

        Parameter entries

        Array of entries, where each entry is an array of [key, value].

        Parameter customStore

        Method to get a custom store. Use with caution (see the docs).

      function update

      update: <T = any>(
      key: IDBValidKey,
      updater: (oldValue: T | undefined) => T,
      customStore?: UseStore
      ) => Promise<void>;
      • Update a value. This lets you see the old value and update it as an atomic operation.

        Parameter key

        Parameter updater

        A callback that takes the old value and returns a new value.

        Parameter customStore

        Method to get a custom store. Use with caution (see the docs).

      function values

      values: <T = any>(customStore?: UseStore) => Promise<T[]>;
      • Get all values in the store.

        Parameter customStore

        Method to get a custom store. Use with caution (see the docs).

      Type Aliases

      type UseStore

      type UseStore = <T>(
      txMode: IDBTransactionMode,
      callback: (store: IDBObjectStore) => T | PromiseLike<T>
      ) => Promise<T>;

        Package Files (1)

        Dependencies (1)

        Dev Dependencies (23)

        Peer Dependencies (0)

        No peer dependencies.

        Badge

        To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

        You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/idb-keyval.

        • Markdown
          [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/idb-keyval)
        • HTML
          <a href="https://www.jsdocs.io/package/idb-keyval"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>