-
Notifications
You must be signed in to change notification settings - Fork 3
Storage
#Storage
A persistent way for plugins to store data.
There are 2 types of storage available to a plugin:
This storage is shared between all plugins and they all can write and read from there. It is not recommended to put sensitive or important information here, it could be gone or even worse, compromised at any moment. If you want to share information between 2 plugins on the other hand, for example cached objects, this is the storage for you.
It is available through api.sharedStorage.
Private storage, as the name implies, is only available to the current plugin. Sensitive information can go here, but there is no easy way to give other plugins access to this storage.
It is available through the 2nd argument of a plugin's load function.
Both, sharedStorage and private storage, are already initiated instances of Node-Persist and very similar in usage to a browser's localstorage. This gives the basic functions, if you want to know more, head over to Node-Persist's GitHub page
Store a value with a key. Returns a promise that resolves when the key has been saved to disk sucessfully or rejects on error.
Retrieve a value from the storage. Undefined if value has not been set.
Delete a key from storage. Returns a promise that resolves when the key has been removed from disk successfully or rejects on error.
Delete all stored key-value pairs. Returns a promise that resolves when the files have been removed from disk or rejects on error.
Returns an array with every key in storage.
##See also API - The API Object for all plugins