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.
const store = require('./common/store');
Creates or updates a store item.
Parameter | Type | Description |
---|---|---|
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);
Gets a store item.
Parameter | Type | Description |
---|---|---|
key | string |
The store item key. |
var data = store.getValue('myPlugin.data.key');