data-chest
v4.1.0
Published
A package for storing values in key-value pairs for NodeJS applications.
Downloads
7
Maintainers
Readme
data-chest
A package for storing values in key-value pairs for NodeJS applications.
install
Do the followingcommand in console:
npm i data-chest
To get the CLI:
npm i -g data-chest
docs
Visit http://datachest.tk/ for the documentation of this.
example
var data = require("data-chest");
//initializes database storage
data.init();
//creates a database
data.create("grades");
data.create("missing");
//stores a value
data.store("Term Paper", "92%", "grades");
data.store("Journal", "96%", "grades");
data.store("Term Paper", "no", "missing");
data.store("Journal", "no", "missing");
//get a value from the database
let x = data.get("Term Paper", "grades");
console.log(x);
x = data.get("Journal", "grades");
console.log(x);
//search for a value
let y = data.search("Term Paper", "*");
console.log(y);
y = data.search("Journal", "*");
console.log(y);
//clear a tag from a database
data.clearTag("Term Paper", "grades");
//clear a database entirely
data.clear("grades");
//remove a database
data.remove("grades");
//list all databases
data.list();
//creates a backup of the databases with an optional name.
data.backup();
This returns
92%
96%
[ { key: 'Term Paper', value: '92%', database: 'grades' },
{ key: 'Term Paper', value: 'no', database: 'missing' } ]
[ { key: 'Journal', value: '96%', database: 'grades' },
{ key: 'Journal', value: 'no', database: 'missing' } ]
[ 'missing' ]
Created a backup of missing
table
An example table can be found in the tests/database
directory.
cli
If you globally installed data-chest, you get access to a CLI.
Do:
data-chest -h
For help. You can also use the alias command dc
.
Use:
dc -h
if you do not feel like typing out the full name.