npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

modokdb

v0.1.0-16

Published

In-memory Database

Downloads

6

Readme

modokDB

In-memory Database

modokDB is a small high performant in-memory database powered by JavaScript Maps (supports Node, Electron and the browser)

NPM

Travis Codecov Issues Github All Releases Forks Stars License Package CodeOfConduct

The Problem

You are looking for a database that is simple and without any dependencies to install.

The Solution

modokDB is a high performant and convenient method for storing data without setting up a database server. It is fast and excellent to be used as an embedded database.

Installation

This module is distributed via npm which is bundled with node and should be installed as one of your project's dependencies:

npm install --save modokdb

Alternatively, if you're using yarn

yarn add modokdb

A UMD build is also available on unpkg for testing and quick prototyping:

<script src="https://unpkg.com/modokdb/dist/modokdb.min.js"></script>
<script>
  var db = new modokdb('users')
</script>

Usage

Without file storage:

const Modok = require('modokdb');
const db = new Modok('users');

With file storage:

const Modok = require('modokdb');
const db = new Modok('users', { filepath: './data/users', filename: 'database' });

db.ready.then(() => {
  console.log('Database file is ready');
});

db.has - Synchronous (returns true / false)

const isAvailable = db.has(<index>); 

db.$has - Asynchronous (returns true / false)

db.$has(<index>).then((value) => {
    console.log(value);
}); 

db.insert - Synchronous (returns database entry)

const user = db.insert({ _id: 0, first_name: 'John', last_name: 'Doe', age: 29 });
console.log('User', user)

db.insert - Synchronous (returns database entries)

const users = db.insert([{ _id: 0, first_name: 'John', last_name: 'Doe', age: 29 }, 
                         { _id: 1, first_name: 'Jane', last_name: 'Doe', age: 27 }]);
console.log('Users', users)

db.$insert - Asynchronous (returns database entry)

db.$insert({ _id: 1, first_name: 'Jane', last_name: 'Doe', age: 27 }).then((user) => {
    console.log('User', user);
});

db.$insert - Asynchronous (returns database entries)

db.$insert([{ _id: 0, first_name: 'John', last_name: 'Doe', age: 29 }, 
            { _id: 1, first_name: 'Jane', last_name: 'Doe', age: 27 }]).then((users) => {
    console.log('Users', users);
});

db.insertOne - Synchronous (returns database entry / entries)

const user = db.insertOne({ _id: 0, first_name: 'John', last_name: 'Doe', age: 29 });
console.log('User', user)

db.$insertOne - Asynchronous (returns database entry / entries)

db.$insertOne({ _id: 1, first_name: 'Jane', last_name: 'Doe', age: 27 }).then((user) => {
    console.log('User', user);
});

db.insertMany - Synchronous (returns database entry / entries)

const users = db.insertMany([{ _id: 0, first_name: 'John', last_name: 'Doe', age: 29 }, 
                             { _id: 1, first_name: 'Jane', last_name: 'Doe', age: 27 }]);
console.log('Users', users)

db.$insertMany - Asynchronous (returns database entry / entries)

db.$insertMany([{ _id: 0, first_name: 'John', last_name: 'Doe', age: 29 }, 
                { _id: 1, first_name: 'Jane', last_name: 'Doe', age: 27 }]).then((users) => {
    console.log('Users', users);
});

db.find - Synchronous (_returns database entry / null)

const users = db.find({ last_name: 'Doe' });
console.log('Users', users)

db.$find - Asynchronous (_returns database entry / null)

db.$find({ last_name: 'Doe' }).then((users) => {
    console.log('Users', users);
});

db.findOne - Synchronous (_returns database entry / null)

const users = db.findOne({ last_name: 'Doe' });
console.log('User', users)

db.$findOne - Asynchronous (_returns database entry / null)

db.$findOne({ last_name: 'Doe' }).then((users) => {
    console.log('User', users);
});

db.findOneAndDelete - Synchronous (_returns database entry / null)

const users = db.findOneAndDelete({ last_name: 'Doe' });
console.log('User', users)

db.$findOneAndDelete - Asynchronous (_returns database entry / null)

db.$findOneAndDelete({ last_name: 'Doe' }).then((users) => {
    console.log('User', users);
});

db.update - Synchronous (_returns database entry / null)

const updatedUsers = db.update({ first_name: 'Jane' }, { age: 45, last_name: 'Mayer' });
console.log('updatedUsers', updatedUsers)

db.$update - Asynchronous (_returns database entry / null)

db.$update({ first_name: 'Jane' }, { age: 45, last_name: 'Mayer' }).then((users) => {
    console.log('users', users);
});

db.update - upsert : true - Synchronous (_returns database entry / null)

const updatedUsers = db.update({ first_name: 'Jane' }, { age: 45, last_name: 'Mayer' }, { upsert: true });
console.log('updatedUsers', updatedUsers)

db.$update - upsert : true - Asynchronous (_returns database entry / null)

db.$update({ first_name: 'Jane' }, { age: 45, last_name: 'Mayer' }, { upsert: true }).then((users) => {
    console.log('users', users);
});

db.updateOne - Synchronous (_returns database entry / null)

const updatedUser = db.updateOne({ first_name: 'Jane' }, { age: 45, last_name: 'Mayer' });
console.log('updatedUser', updatedUser)

db.$updateOne - Asynchronous (_returns database entry / null)

db.$updateOne({ first_name: 'Jane' }, { age: 45, last_name: 'Mayer' }).then((user) => {
    console.log('user', user);
});

db.updateMany - Synchronous (_returns database entry / null)

const updatedUsers = db.updateMany({ first_name: 'Jane' }, { age: 45, last_name: 'Mayer' });
console.log('updatedUsers', updatedUsers)

db.$updateMany - Asynchronous (_returns database entry / null)

db.$updateMany({ first_name: 'Jane' }, { age: 45, last_name: 'Mayer' }).then((users) => {
    console.log('users', users);
});

db.count - Synchronous (returns integer)

const count = db.count();
console.log('Count', count);

db.$count - Asynchronous (returns integer)

db.$count().then((value) => {
  console.log('Count', value);
});

db.drop - Synchronous (returns empty object)

db.drop();

db.$drop - Asynchronous (returns empty object)

db.$drop().then(() => {
  
});

db.delete - Synchronous (returns true / false)

db.delete({ last_name: 'Doe' });

db.$delete - Asynchronous (returns true / false)

db.$delete({ last_name: 'Doe' }).then(() => {
  
});

db.deleteOne - Synchronous (returns true / false)

db.deleteOne({ last_name: 'Doe' });

db.$deleteOne - Asynchronous (returns true / false)

db.$deleteOne({ last_name: 'Doe' }).then(() => {
  
});

db.deleteOne - Synchronous (returns true / false)

db.deleteMany({ last_name: 'Doe' });

db.$deleteOne - Asynchronous (returns true / false)

db.$deleteMany({ last_name: 'Doe' }).then(() => {
  
});

db.deleteOneById - Synchronous (returns true / false)

db.deleteOneById(2);

db.$deleteOne - Asynchronous (returns true / false)

db.$deleteOneById(2).then(() => {
  
});

db.stats - Synchronous (returns object)

const db = new Modok('users', { filepath: './data/users', filename: 'database' });
const stats = db.stats();
console.log('Stats', stats);

db.$stats - Asynchronous (returns object)

const db = new Modok('users', { filepath: './data/users', filename: 'database' });

db.$stats().then((stats) => {
  console.log('Stats', stats);
});

Collection Reference

# File: 1
const db = new Modok('users', { filepath: './data/users', filename: 'database' });

# File: 2
const usersRef = Modok('users');
const results = usersRef.find({ last_name: 'Doe' });
console.log('results', results);

db.renameCollection - Synchronous (returns collection reference)

const db = new Modok('users');
const newDB = db.renameCollection('accounts');
console.log('newDB', newDB);

db.$renameCollection - Asynchronous (returns collection reference)

const db = new Modok('users');

db.$renameCollection('accounts').then((newDB) => {
  console.log('newDB', newDB);
});

Contributors

LICENSE

MIT