Skip to content

kutluturk/memdb-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

In-Memory Database For JSON Objects that can be queried like SQL

This package is intended to be used as a drop-in small footprint Object database solution for Node.JS.

How to Install

npm install --save memdb-json

Usage

This package is still in alpha stage. Please be aware before using in production environment.

Initialization

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.

Insert an object to the DB

MemDB.insert({id: 1, Name: "Halil", Surname: "Kutluturk", Age: 45, City: "Berlin", Country: "Germany"});

Returns a UUID of the object inserted to the DB

Select object(s) from 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

Update an Object in the DB

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

Delete object(s) from the DB

MemDB.delete({where: {id: 1}})

Empty (truncate) the DB

MemDB.truncate();

Save the Objects in the DB to a JSON file (persistant data storage)

MemDB.save(pathToFile);

About

Very fast in memory object DB for Node.JS.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published