@ionic/storage

  • Version 3.0.6
  • Published
  • 589 kB
  • 1 dependency
  • MIT license

Install

npm i @ionic/storage
yarn add @ionic/storage
pnpm add @ionic/storage

Overview

Ionic Storage Helper

Index

Variables

variable Drivers

const Drivers: { SecureStorage: string; IndexedDB: string; LocalStorage: string };

Classes

class Storage

class Storage {}

    constructor

    constructor(config?: StorageConfig);
    • Create a new Storage instance using the order of drivers and any additional config options to pass to LocalForage.

      Possible default driverOrder options are: ['indexeddb', 'localstorage'] and the default is that exact ordering.

      When using Ionic Secure Storage (enterprise only), use ['ionicSecureStorage', 'indexeddb', 'localstorage'] to ensure Secure Storage is used when available, or fall back to IndexedDB or LocalStorage on the web.

    property driver

    readonly driver: string;
    • Get the name of the driver being used.

      Returns

      Name of the driver

    method clear

    clear: () => Promise<void>;
    • Clear the entire key value store. WARNING: HOT!

      Returns

      Returns a promise that resolves when the store is cleared

    method create

    create: () => Promise<Storage>;

      method defineDriver

      defineDriver: (driver: Driver) => Promise<void>;
      • Define a new Driver. Must be called before initializing the database. Example:

        await storage.defineDriver(myDriver); await storage.create();

      method forEach

      forEach: (
      iteratorCallback: (value: any, key: string, iterationNumber: Number) => any
      ) => Promise<void>;
      • Iterate through each key,value pair.

        Parameter iteratorCallback

        a callback of the form (value, key, iterationNumber)

        Returns

        Returns a promise that resolves when the iteration has finished.

      method get

      get: (key: string) => Promise<any>;
      • Get the value associated with the given key.

        Parameter key

        the key to identify this value

        Returns

        Returns a promise with the value of the given key

      method keys

      keys: () => Promise<string[]>;
      • Returns

        Returns a promise that resolves with the keys in the store.

      method length

      length: () => Promise<number>;
      • Returns

        Returns a promise that resolves with the number of keys stored.

      method remove

      remove: (key: string) => Promise<any>;
      • Remove any value associated with this key.

        Parameter key

        the key to identify this value

        Returns

        Returns a promise that resolves when the value is removed

      method set

      set: (key: string, value: any) => Promise<any>;
      • Set the value for the given key.

        Parameter key

        the key to identify this value

        Parameter value

        the value for this key

        Returns

        Returns a promise that resolves when the key and value are set

      method setEncryptionKey

      setEncryptionKey: (key: string) => void;

        Interfaces

        interface StorageConfig

        interface StorageConfig {}

          property dbKey

          dbKey?: string;

            property description

            description?: string;

              property driverOrder

              driverOrder?: Driver[];

                property name

                name?: string;

                  property size

                  size?: number;

                    property storeName

                    storeName?: string;

                      property version

                      version?: number;

                        Type Aliases

                        type Database

                        type Database = any;

                          Package Files (1)

                          Dependencies (1)

                          Dev Dependencies (7)

                          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/@ionic/storage.

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