IDBStore

Source IDBStore

constructor

new IDBStore(dbName, storeName);

Creates a new IDBStore instance.

Parameters

  1. dbName - string (default = ‘keyval-store’): database name;
  2. storeName - string (readonly, default = ‘keyval’): store name within the database;

Returns

IDBStore instance

Example

this.ipfsCacheStore = new IDBStore('ipfs-cache', 'ipfs-hashes');

getDefaultStore

ipfsCacheStore.getDefaultStore();

private: creates a new store or returns the latest one

Returns

Promise returns void: resolved when done

Example

// ...

get

ipfsCacheStore.get<Type>(key, store);

Gets a key from the IDB store.

Parameters

  1. key - IDBValidKey: key to load
  2. store - IDBStore (default = getDefaultStore()): idb store to load the data from

Returns

Promise returns Type: returns a key value from idb store

Example

const result = await ipfsCacheStore.get('sample-key')

set

ipfsCacheStore.set(key, value, store);

sets a key value in a idb store

Parameters

  1. key - IDBValidKey: key to set the value for
  2. value - any: value to set
  3. store - IDBStore (default = getDefaultStore()): idb store to set the value in

Returns

Promise returns void: resolved when done

Example

await ipfsCacheStore.set('sample-key', 'cool value')

del

ipfsCacheStore.del(del, store);

delete a key from an idb store

Parameters

  1. key - IDBValidKey: key to delete
  2. store - Function (default = getDefaultStore()): idb store to delete the data from

Returns

Promise returns void: resolved when done

Example

await ipfsCacheStore.del('sample-key')

clear

ipfsCacheStore.clear(store);

Clears an idb store

Parameters

  1. store - IDBStore (default = getDefaultStore()): The store;

Returns

Promise returns void: resolved when done

Example

await ipfsCacheStore.clear();

keys

ipfsCacheStore.keys(store);

Gets the keys from an idb store

Parameters

  1. store - IDBStore (default = getDefaultStore()): The store;

Returns

Promise returns IDBValidKey[]: keys of the idb store

Example

const keys = ipfsCacheStore.keys();