Storage interface

Interface for a storage provider that stores and retrieves plain old JSON objects.

Methods

delete(string[])

Removes store items from storage

read(string[])

Loads store items from storage

write(StoreItems)

Saves store items to storage.

Method Details

delete(string[])

Removes store items from storage

function delete(keys: string[]): Promise<void>

Parameters

keys

string[]

Array of item keys to remove from the store.

Returns

Promise<void>

Remarks

This example deletes an object from storage:

await storage.delete(['botState']);

read(string[])

Loads store items from storage

function read(keys: string[]): Promise<StoreItems>

Parameters

keys

string[]

Array of item keys to read from the store.

Returns

Promise<StoreItems>

Remarks

This example reads in a single object from storage:

const items = await storage.read(['botState']);
const state = items['botState'] || {};

write(StoreItems)

Saves store items to storage.

function write(changes: StoreItems): Promise<void>

Parameters

changes
StoreItems

Map of items to write to storage.

Returns

Promise<void>

Remarks

This example writes an object to storage after its been modified:

state.topic = 'someTopic';
await storage.write({ 'botState': state });