Options
All
  • Public
  • Public/Protected
  • All
Menu

Class IndexedStorage

Loki persistence adapter class for indexedDb. This class fulfills abstract adapter interface which can be applied to other storage methods. Utilizes the included LokiCatalog app/key/value database for actual database persistence. IndexedDb storage is provided per-domain, so we implement app/key/value database to allow separate contexts for separate apps within a domain.

Hierarchy

  • IndexedStorage

Implements

Index

Constructors

constructor

Methods

deleteDatabase

  • deleteDatabase(dbname: string): Promise<void>
  • Deletes a serialized db from the catalog.

    example

    // DELETE DATABASE // delete "finance"/"test" value from catalog idbAdapter.deleteDatabase("test", function { // database deleted });

    Parameters

    • dbname: string

      the name of the database to delete from the catalog.

    Returns Promise<void>

    a Promise that resolves after the database was deleted

deleteDatabasePartitions

  • deleteDatabasePartitions(dbname: string): void
  • Removes all database partitions and pages with the base filename passed in. This utility method does not (yet) guarantee async deletions will be completed before returning

    Parameters

    • dbname: string

      the base filename which container, partitions, or pages are derived

    Returns void

getCatalogSummary

  • getCatalogSummary(callback: function): void
  • Allows retrieval of list of all keys in catalog along with size

    Parameters

    • callback: function

      (Optional) callback to accept result array.

        • Parameters

          Returns void

    Returns void

getDatabaseList

  • getDatabaseList(callback: function): void
  • Retrieves object array of catalog entries for current app.

    example

    idbAdapter.getDatabaseList(function(result) { // result is array of string names for that appcontext ("finance") result.forEach(function(str) { console.log(str); }); });

    Parameters

    • callback: function

      should accept array of database names in the catalog for current app.

        • (names: string[]): void
        • Parameters

          • names: string[]

          Returns void

    Returns void

loadDatabase

  • loadDatabase(dbname: string): Promise<Object>
  • Retrieves a serialized db string from the catalog.

    example

    // LOAD var idbAdapter = new LokiIndexedAdapter("finance"); var db = new loki("test", { adapter: idbAdapter }); db.base(function(result) { console.log("done"); });

    Parameters

    • dbname: string

      the name of the database to retrieve.

    Returns Promise<Object>

    a Promise that resolves after the database was loaded

saveDatabase

  • saveDatabase(dbname: string, dbstring: string): Promise<void>
  • Saves a serialized db to the catalog.

    example

    // SAVE : will save App/Key/Val as "finance"/"test"/{serializedDb} let idbAdapter = new LokiIndexedAdapter("finance"); let db = new loki("test", { adapter: idbAdapter }); let coll = db.addCollection("testColl"); coll.insert({test: "val"}); db.saveDatabase(); // could pass callback if needed for async complete

    Parameters

    • dbname: string

      the name to give the serialized database within the catalog.

    • dbstring: string

      the serialized db string to save.

    Returns Promise<void>

    a Promise that resolves after the database was persisted

Static deregister

  • deregister(): void

Static register

  • register(): void

Generated using TypeDoc