iojdb
v2.1.2
Published
Scalable Json DB
Downloads
42
Readme
const JsonDB = require("iojdb");
const db = JsonDB("./path/to/JsonDB-Data/");
JsonDB(path/to/database/folder)
.open(collName) - open and create collection
.insert([documentObject]) - number of docs inserted
.find(queryObject) - array of docs found
.findOne(queryObject) - doc if found or false
.update(queryObject, updatedDocumentObject) - number of docs updated
.remove(queryObject) - number of docs removed
.destroy() - destroy the collection and its data
.get(collName) - get collection if exists
.list() - list all collection names
.exist(collName) - check if collection exists
.delete(collName) - delete existing collection
.destroy() - destroy the database and its data
const coll = db.open("CollectionName");
let DocumentObject = {
first_name: "John",
last_name: "Silver",
num: 88,
tf: false,
nu: null,
}
let QueryObject = {
first_name: "John",
last_name: (v) => v.startsWith("S"),
};
let insertCount = coll.insert([DocumentObject]);
let documentObjectArray = coll.find(QueryObject); // [DocumentObject]
let updateCount = coll.update(QueryObject, { num: 77 });
let documentObject = coll.findOne(QueryObject); // DocumentObject, but with num = 77
let removedCount = coll.remove(QueryObject);