somewhere.js
Small in-memory database for Node.js that persists on disk
Installation
$ npm install somewhere
Usage
Load
var Database = ;
Create database
var onlyMemoryDb = ;var memoryDiskDb = './database.json';
Database connection
var db = './database.json';
Save
db;
var movie = title: "Die Hard" genre: "Action" director: "John McTiernan" description: "John McClane, officer of the NYPD, tries to save wife Holly Gennaro and several others, taken hostage by German terrorist Hans Gruber during a Christmas party at the Nakatomi Plaza in Los Angeles."; db; /** Result: Saved Object (autogenerated id) { id: "0ab7d8a8-ab46-35cd-ccd4-81ccfe81c3f1", title: "Die Hard", genre: "Action", director: "John McTiernan", description: "John McClane, officer of the NYPD, tries to save wife Holly Gennaro and several others, taken hostage by German terrorist Hans Gruber during a Christmas party at the Nakatomi Plaza in Los Angeles." }*/
Find one
db;
db; /** Result: Object { id: "0ab7d8a8-ab46-35cd-ccd4-81ccfe81c3f1", title: "Die Hard", genre: "Action", director: "John McTiernan", description: "John McClane, officer of the NYPD, tries to save wife Holly Gennaro and several others, taken hostage by German terrorist Hans Gruber during a Christmas party at the Nakatomi Plaza in Los Angeles." }*/
Find all
db;
db; /** Result: Objects array [{ id: "0ab7d8a8-ab46-35cd-ccd4-81ccfe81c3f1", title: "Die Hard", genre: "Action", director: "John McTiernan", description: "John McClane, officer of the NYPD, tries to save wife Holly Gennaro and several others, taken hostage by German terrorist Hans Gruber during a Christmas party at the Nakatomi Plaza in Los Angeles." }]*/
Update
db;
db; /** Result: Updated Object { id: "0ab7d8a8-ab46-35cd-ccd4-81ccfe81c3f1", title: "Die Hard", genre: "Action/Thriller", director: "John McTiernan", description: "John McClane, officer of the NYPD, tries to save wife Holly Gennaro and several others, taken hostage by German terrorist Hans Gruber during a Christmas party at the Nakatomi Plaza in Los Angeles." }*/
Remove
db;
db;/** Result: Boolean true*/
Clear database
dbclear
License
This software is free to use under the MIT license.