Published on

Memoz

Authors

Memoz

npm version  https://img.shields.io/npm/dm/memoz.svg

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.

  1. Installation
  2. Usage
  3. Methods

Installation

npm i memoz
// or
yarn add memoz

Usage

const Memoz = require('memoz');
// Or
import Memoz from 'memoz';

Methods

  1. create
  2. updateMany
  3. updateOne
  4. get
  5. getOne
  6. deleteMany
  7. deleteOne

create

This method takes two parameters:

  1. key, this is a string
  2. value, this is an any, maybe string, 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:

  1. query, this is a object contains keys and values, it will be AND, this is required
  2. newData, this is an any, maybe string, number, object, array any valid data types in javascript, this is required
const memoz = new Memoz();

const person = memoz.updateMany('name', 'Milad');
// { updated: true }

updateOne

This method takes two parameters:

  1. query, this is a object contains keys and values, it will be AND, this is required
  2. newData, this is an any, maybe string, number, object, array any valid data types in javascript, this is required
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" }}