Skip to main content

Introduction

The stores module exposes methods for creating and managing plugin stores.

Plugin store is a temporary realtime database provided with Plugin SDK that can help you manage your data better. Each entry in the store is a key-pair value.

The value can assume the following types:

Data Types
String
Number
Object
Array
Map
Set

Create a Store

You can create a global store (Realtime store) or a local store (Available only to you, not other users).

note

This method only creates a store for the current user (self), hence it must be executed for every user.

ParamTypeDescriptionDefault ValueRequired
keystringName of the store.-true
optionsOptionsThe options object{ local: false }false
options.localbooleanCreates a local store when true.falsefalse
type Options = {
local: boolean;
};
// create a global store
plugin.stores.create('myStore');

// create a local store
const options: Options = { local: true };
plugin.stores.create('myLocalStore', options);

Populate Stores

The populate method populates the global plugin stores from the backend. Ideally used right after initialisation.

await plugin.stores.populate('myStore');

Delete a Store

You can delete a store using the store name.

ParamTypeDescriptionDefault ValueRequired
keystringName of the store.-true
optionsOptionsThe options object{ local: false }false
options.localbooleanDeletes a local store when true.falsefalse
// delete a global store
await plugin.stores.delete('myStore');

// delete a local store
plugin.stores.delete('myLocalStore', { local: true });

Get a Store

You can fetch a global store using the store name.

ParamTypeDescriptionDefault ValueRequired
keystringName of the store.-true
optionsOptionsThe options object{ local: false }false
options.localbooleanGets a local store when true.falsefalse
// get a global store
const store = plugin.stores.get('myStore');

// get a local store
const localStore = plugin.stores.get('myLocalStore', { local: true });