Skip to content

tiagorangel2011/qjson-db

 
 

Repository files navigation

🍩 Note: If you want a database with more features (e.g. math, etc.), I hightly recommend you looking at jsoning by @khalby786

qjson-db: Dead simple JSON database


A fork of nmaggioni/Simple-JSONdb, this is a dead simple JSON database for your web app.

Install: npm i qjson-db

Usage

Start by creating your database:

const qjson = require('qjson-db');
const db = new qjson('/path/to/your/storage.json');

Then, you can use the functions:

Set a key

db.set('key', 'value');

The key parameter must be a string, value can be whatever kind of object can be stored in JSON format.

Get a key

db.get('key');

The key parameter must be a string. If the key exists its value is returned, if it doesn't the function returns undefined.

Check a key

db.has('key');

The key parameter must be a string. If the key exists true is returned, if it doesn't the function returns false.

Delete a key

db.delete('key');

The key parameter must be a string. The function returns as per the delete operator if the key exists, else it returns undefined.

Access JSON storage

db.JSON();

This will return a copy of the internal JSON storage object.

Replace JSON storage

db.JSON({ data });

Giving a parameter to the JSON function makes the object passed replace the internal one. Be careful, as there's no way to recover the old object if the changes have already been written to disk.

About

An easy-to-use JSON database

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%