Store

API to read and write data to the YAKjs key/value store. The store is also accessible via the web interface. A key can be namespaced with '.', use only for a better visualization on the web interface.

Usage

const store = require('./common/store');

setValue(key, value)

Creates or updates a store item.

ParameterTypeDescription
key

string

The unique key for the item.

value

string

The item value.

store.setValue('myPlugin.data.key', 'Any string');

To store an object it needs to be serialized to a string. Since version 2.x a jsonStore is available, that does the serialization for you to keep your plugin code clean.

var contacts= [{name: 'Hugo', email: 'hugo@example.com'}];
var data = JSON.stringify(newContact, null, 2);
store.setValue('myPlugin.data.key', value);

getValue(key)

Gets a store item.

ParameterTypeDescription
key

string

The store item key.

var data = store.getValue('myPlugin.data.key');