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 🙏

© 2025 – Pkg Stats / Ryan Hefner

nedb_node_util

v1.3.9

Published

Utility to work with the NEDB embedded database with ease

Readme

NEDB Node Utils

A Node helper to work with the embedded NEDB datastore

Install

  npm i --save nedb_node_util
  

Usage


    // require this package
    var _datastore = require("nedb_node_util");

    // calling this function returns an obj that we can 
    // use to work with our database
    const _db = _datastore();

    
    // we first need to initialise the db
    _db.init(); 
    
    // or we can create a datastore by setting db name and path 
    _db.init( "myDB", "/my/db/path" );
    

Then once we have the DB initalised, the helpers all return promises which we can implement in 2 different ways:


Simple Key / Value Store

The following methods are avaiable:

setValue(key, value) : any string key to store any data type

  // using promises then() and catch()
    _db
    .setValue(key, value)
    .then(savedValue => {
      console.log(savedValue);
    })
    .catch(er => {
      console.log(er.error);
    });

or


  // using async / await instead of promises
  let result = await _db.getQuery({}, skip, count); 
  if(result.hasOwnProperty('error')){
    // result will be the error object from mongo
    return result.error
  }
  return result
  

getValue( key ) : get a stored value by it's string key

    _db
    .getValue(key)
    .then(result => {
      console.log(result);
    })
    .catch(er => {
      console.log(er.error);
    });


Typical Mongo Document DB

The following methods are available:

setObject( object ) : here you can implement your own document structure

    _db
    .setObject(object)
    .then(savedValue => {
      console.log(savedValue);
    })
    .catch(er => {
      console.log(er.error);
    });

updateObject( query, object ) : here you can update your own document structure

    _db
    .updateObject(object)
    .then(updatedValue => {
      console.log(updatedValue);
    })
    .catch(er => {
      console.log(er.error);
    });

getQuery(query, skip = 0, count = 100) : here you can pass mongo query objects based on your custom object structures

    _db
    .getQuery(query, 0, 500) // skip 0 and limit to 100 docs
    .then(results => {
      console.log(results);
    })
    .catch(er => {
      console.log(er.error);
    });


Database Maintenance Methods

getKeys() : _will return the ids of the stored objects

    _db
    .getKeys()
    .then(results => {
      console.log(results); // [{key: 'DATABASE_KEYS', value: '<This is the _id of the stored object>', _id" 'Mongo _id of the keys document'},...]
    })
    .catch(er => {
      console.log(er.error);
    });

deleteObjectByKey( id ) : removes a single document using its id


  _db
    .deleteObjectByKey(_id)
    .then(results => {
      console.log(results); // this object will have the db changes
    })
    .catch(er => {
      console.log(er.error);
    });

getQueryCount( query ) : here you can pass mongo query object and get the document count that would be returned

    _db
    .getQueryCount(query) // skip 0 and limit to 100 docs
    .then(results => {
      console.log(results);
    })
    .catch(er => {
      console.log(er.error);
    });

deleteObjectByQuery( query ) : removes all object or values matching the mongo query object


  _db
    .deleteObjectByQuery(query)
    .then(results => {
      console.log(results); // this object will have the db changes
    })
    .catch(er => {
      console.log(er.error);
    });

clearDB() : removes all objects from the datastore


  _db
    .clearDB(query)
    .then(results => {
      console.log(results); // this object will have the db changes
    })
    .catch(er => {
      console.log(er.error);
    });

clearDBKEYS() - : removes all key references from the datastore


  _db
    .clearDBKEYS()
    .then(results => {
      console.log(results); // this object will have the db changes
    })
    .catch(er => {
      console.log(er.error);
    });