@codehubby/mangodb
v1.0.3
Published
MangoDB: Key-Value Database, Queries Written in JavaScript
Downloads
3
Readme
MangoDB: Key-Value Database, Queries Written in JavaScript
- 💜 Write Queries in JavaScript
- 💜 Agentless Connection
- 💜 Super Fast Reads
A https://hub.codehubby.com package to radically simplify your app's database. Write Queries in JavaScript. Powered by LMDB and SQLite.
index.js:
import { Mango } from './mango.js';
const mango = new Mango('mangotest');
// create
let [_id1, promise1] = await mango.create('notes',{price:1,'title':'first'})
let [_id2, promise2] = await mango.create('notes',{price:6,'title':'second'})
let [_id3, promise3] = await mango.create('notes',{price:3,'title':'third'})
await Promise.all([promise1,promise2,promise3])
// read
const list1 = mango.read('notes',{
filter: (item) => {
return item.price < 5;
},
sort: (a,b) => {
return b.price-a.price;
},
skip:0,
limit:10,
});
console.log({list1})
// update
console.log(await mango.update('notes',{ set: { price:99 }, filter: (item) => {
return item.price < 5;
}}))
// delete
console.log(await mango.delete('notes',{ filter: (item) => {
return item.price < 99;
}}))
Quick Tip to Use Import / ES6 with NodeJS:
Add this to your package.json file
"type":"module",