Storage

Storage

Singleton that provides functions persist data. Data is persisted in in files defined inside the data directory. Fetches all different files of the data directory into a single object.

Constructor

new Storage()

Version:
  • 1.0
Author:
  • Maksim Sandybekov
Source:

Methods

(static) getInstance()

Singleton method. Create and keep only a single object of the storage around.
Source:

set(key, value) → {Object}

Adding values to data files. Creating the if they are not existent.
Parameters:
Name Type Description
key string Single or multi path segment separated by dots (Examples: 'key', 'key.nested_key', ...)
value * The value to save under given key
Source:
Examples
add("queue.users", 22); // store {"users": 22} inside a file named queue.json
add("queue.1231.servername", "Test Server"); // store {"1231": {"servername": "Test Server"}} inside a file named queue.json

get(key) → {null|*}

Searches for a value under given key.
Parameters:
Name Type Description
key string Single/Multi-path segement separated by dots. (Example: 'key', 'key.nested_key', 'users.count', ...)
Source:
Examples
get("queue.member"); // Returns the value saved under given key or undefined
get("queue"); // Returns whole content of queue.json file