dbjsond
v1.0.5
Published
Quick and easy database for Node.js.
Downloads
126
Maintainers
Readme
dbjsond
Quick and easy embeddable database for Node.js.
The module stores all the data within the in-memory representation and optionally saves it in JSON file.
Requirements
This module requires Node.js v6.*
Install
npm install dbjsond
Example
See example folder for more complex examples.
In-Memory
const dbjsond = require('dbjsond'), db = new dbjsond(':memory');
db.add('Name', 'Value').add('Name2', 'Value2');
// {'Name': 'Value', 'Name2': 'Value2'}
db.get('Name');
// return Value
db.remove('Name').remove('Name2');
// {}
File
const dbjsond = require('dbjsond'), db = new dbjsond('/path/to/json');
db.add('Name', 'Value').add('Name2', 'Value2');
// {'Name': 'Value', 'Name2': 'Value2'}
db.get('Name');
// return Value
db.save();
API
db.add(Name, Value, Collection = optional) // returns this
Adds a named value.
db.get(Name, Collection = optional) // returns value
Returns a key value.
db.getAll(Collection = optional) // returns {}
Returns a full temp object or collection.
db.remove(Name, Collection = optional) // returns this
Removes a key.
db.setCollection(Collection) // returns this
Sets collection name (which is used by db.add() db.get() db.remove()).
db.unsetCollection() // returns this
Unsets collection name.
db.removeCollection(Collection) // returns this
Removes collection from the database object.
db.save()
Saves database object in file.
db.autosave(data, timer = optional)
Starts database autosaving.
NOTE data must be db._tempMemory.
Contributor
License
dbjsond
is MIT licensed.