This package is intended to be used as a drop-in small footprint Object database solution for Node.JS.
npm install --save memdb-json
This package is still in alpha stage. Please be aware before using in production environment.
const memdb = require('memdb-json');
const MemDB = new memdb(pathToFile); //path to optional JSON file
You can pass an optional JSON file path to the function for persistant data storage.
MemDB.insert({id: 1, Name: "Halil", Surname: "Kutluturk", Age: 45, City: "Berlin", Country: "Germany"});
Returns a UUID of the object inserted to the DB
MemDB.select({where: {City: "Berlin"}});
MemDB.select({where: {Surname: "Smith", Age: 45}}); // You can add multiple keywords
MemDB.select(); //Returns all objects
You can query the DB with "where" keyword.
Returns an array of JSON Objects
MemDB.update({where: {id: 1}, set: {Born: "New York", Surname: "John", Born: "1998-01-01"}});
MemDB.update({where: {Name: "John", Surname: "Smith", Nationality: "USA"}, set: {Born: "New York", Active: true}});
Returns a JSON array with updated Objects
MemDB.delete({where: {id: 1}})
MemDB.truncate();
MemDB.save(pathToFile);