Constructor
new FPersistStoragePlugin(persistenceDir)
- Source:
- Implements:
Example
const FPersistPlugin = require('monochome-bot').Plugins.FPersist;
const storage = new FPersistPlugin(path.join(__dirname, 'storage'));
Parameters:
Name | Type | Description |
---|---|---|
persistenceDir |
String | A full path to the directory to store persistence files. The directory doesn't have to exist, but its parents do. Don't put anything else in the persistence directory. It should be used exclusively by fpersist. |
Methods
(async) clear()
- Description:
- Clear ALL data from storage.
- Source:
- Implements:
(async) close()
- Description:
- Finish all operations and close down. Reads and writes may or may not be accepted after this function is called.
- Source:
- Implements:
(async) deleteKey(key)
- Description:
- Delete the value associated with the given key, clearing it from persistence. If the key already wasn't present, this won't throw.
- Source:
- Implements:
Parameters:
Name | Type | Description |
---|---|---|
key |
String | The key. |
(async) editValue(key, editFn, defaultValueopt) → {*}
- Description:
- Update the value associated with the given key.
- Source:
- Implements:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
key |
String | The key. | |
editFn |
function | A (async or sync) function that takes one argument (the current value retrieved from storage for the given key) and returns the updated value. | |
defaultValue |
* |
<optional> |
The default value to pass into the editFn if no value is present for that key. |
Returns:
The updated value.
- Type
- *
(async) getValue(key, defaultValueopt) → {*}
- Description:
- Get the value associated with the given key.
- Source:
- Implements:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
key |
String | The key. | |
defaultValue |
* |
<optional> |
The default value if no value is present for that key. |
Returns:
The value present in storage,
or the default value if no value is present in storage.
- Type
- *