Skip to main content

Interface: IDataStore

An interface for persisting data.

Remarks

This interface saves activity results as well as saves and retrieves arbitrary key-value items that activities can use.

The underlying persistence provider of the store must be previously set in the activity's Session before use. The implementation of the store is not provided by the @m2c2kit/core library.

Example

import { LocalDatabase } from "@m2c2kit/db";
...
const db: IDataStore = new LocalDatabase();
session.dataStore = db;
session.initialize();

Methods

clearItemsByActivityPublishUuid()

clearItemsByActivityPublishUuid(activityPublishUuid): Promise<void>

Deletes all items.

Parameters

activityPublishUuid: string

Returns

Promise<void>

Defined in

IDataStore.ts:40


deleteItem()

deleteItem(key): Promise<void>

Deletes an item by its key.

Parameters

key: string

Returns

Promise<void>

Defined in

IDataStore.ts:38


getItem()

getItem<T>(key): Promise<T>

Gets the value of an item by its key.

Type Parameters

T extends undefined | null | string | number | boolean | object

Parameters

key: string

Returns

Promise<T>

Defined in

IDataStore.ts:34


itemExists()

itemExists(key): Promise<boolean>

Determines if the key exists.

Parameters

key: string

Returns

Promise<boolean>

Defined in

IDataStore.ts:46


itemsKeysByActivityPublishUuid()

itemsKeysByActivityPublishUuid(activityPublishUuid): Promise<string[]>

Returns keys of all items.

Parameters

activityPublishUuid: string

Returns

Promise<string[]>

Defined in

IDataStore.ts:42


saveActivityResults()

saveActivityResults(ev): Promise<string>

Saves activity results in the data store.

Parameters

ev: ActivityResultsEvent

Returns

Promise<string>

Defined in

IDataStore.ts:24


setItem()

setItem(key, value, activityPublishUuid): Promise<string>

Sets the value of an item. The key will be saved to the store as provided; if namespacing or other formatting is desired, it must be done before calling this method. activityId can be used by the store for indexing.

Parameters

key: string

value: undefined | null | string | number | boolean | object

activityPublishUuid: string

Returns

Promise<string>

Defined in

IDataStore.ts:28