- Published on
Memoz
- Authors
- Name
- Milad E. Fahmy
- @miladezzat12
Memoz
Memoz is an in-memory database that persists on disk. The data model is key-value, but many different kind of values are supported: Strings, Lists, Sets, Sorted Sets, Hashes, Streams, HyperLogLogs, Bitmaps.
Installation
npm i memoz
// or
yarn add memoz
Usage
const Memoz = require('memoz');
// Or
import Memoz from 'memoz';
Methods
create
This method takes two parameters:
key
, this is astring
value
, this is anany
, maybestring
,number
,object
,array
any valid data types in javascript
const memoz = new Memoz();
const person = memoz.create('name', 'john');
// {id: 'sdfd-dsfg455-dfg544fg', name: 'john'}
updateMany
This method takes two parameters:
query
, this is aobject
contains keys and values, it will beAND
, this isrequired
newData
, this is anany
, maybestring
,number
,object
,array
any valid data types in javascript, this isrequired
const memoz = new Memoz();
const person = memoz.updateMany('name', 'Milad');
// { updated: true }
updateOne
This method takes two parameters:
query
, this is aobject
contains keys and values, it will beAND
, this isrequired
newData
, this is anany
, maybestring
,number
,object
,array
any valid data types in javascript, this isrequired
const memoz = new Memoz();
const person = memoz.updateOne('name', 'Milad');
// {id: 'sdfd-dsfg455-dfg544fg', name: 'Milad'}
get
This method take one parameters:
query
, this is a object
contains keys and values, it will be AND
, this is optional
const memoz = new Memoz();
const person = memoz.get({'name':'Milad'});
// [{id: 'sdfd-dsfg455-dfg544fg', name: 'Milad'}]
getOne
This method take one parameters:
query
, this is a object
contains keys and values, it will be AND
, this is required
const memoz = new Memoz();
const person = memoz.getOne({'name':'Milad'});
// {id: 'sdfd-dsfg455-dfg544fg', name: 'Milad'}
deleteMany
This method take one parameters:
query
, this is a object
contains keys and values, it will be AND
, this is required
const memoz = new Memoz();
const person = memoz.deleteMany({'name':'Milad'});
// {deleted: true, number: 5}
deleteOne
This method take one parameters:
query
, this is a object
contains keys and values, it will be AND
, this is required
const memoz = new Memoz();
const person = memoz.deleteOne({'name':'Milad'});
// {deleted: { id: "dslkmds68-dfgh45", name: "Milad" }}