1.0.3 • Published 4 years ago

json-database.js v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

JsonDB

JsonDB is easy to use module, that makes database based on json files.


How to use?

First, install library using command below.

$ npm i json-database.js

Follow the code shown below.

const JsonDB = require('json-database.js');

const db = new JsonDB({
    file: './file.name.json', /* Type there database file path */
    table: 'users' /* Users is example, type one you want */
});

// To set key in database use
await db.set('field', 'value');
// Then to add user admin with password 12345 use:
await db.set('admin', '12345');

// To get value from key in database use
await db.get('field');
// To get password for user admin use:
await db.get('admin');
// If there is no that field, you can add default return value. If not set will return null
await db.get('not existing user', 'test'); // output: "test"

// To remove field use
await db.remove('field');
// If we type code below, user admin will be deleted from database
await db.remove('admin');

// To remove all fields use
await db.clear();

// If you want destroy all data (not only currend table) use this
await db.clearDB();
1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago