nsel

1.1.6 • Public • Published

NSEL

Make nodejs express server & json structured database in 1 line!

const NSEL = require('nsel');

// NSEL INIT
const [app, db] = NSEL.quick('host', 'user', 'password', 'db');

// End Points
app.get('/', (req, res)=>{
    db.set(['users', 'user1', 'password'], '1234'); // set data to db
    let password = db.get(['users', 'user1', 'password']); // get data from db
    res.send(password); // send response
});

Database

NSEL.DB.jdb is a json object, that can be saved in your mysql db with the:

db.saveDB();

command.

but a quicker way to work with this db, is to write the path to the json object in an array. replace this syntax:

db.jdb['a']['b'] = 8; // set
let num = db.jdb['a']['b']; // get

with this syntax:

db.set(['a', 'b'], 8); // set
let num = db.get(['a', 'b']); // get

the set & get functions make sure that undefined objects will be set to {}. that way you can write entire imaginery pathes that doesn't exist and they will be created! another amazing thing is that the set function automaticaly saves the db (unless you set the last parameter to false).

Readme

Keywords

Package Sidebar

Install

npm i nsel

Weekly Downloads

0

Version

1.1.6

License

ISC

Unpacked Size

12.8 kB

Total Files

5

Last publish

Collaborators

  • nimrodnifla