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 🙏

© 2026 – Pkg Stats / Ryan Hefner

pkmongo

v1.0.7

Published

Mongo DB helper

Readme

pk_mongo

Mongo Helper Library

This is a very simple promise based library intended to write queries efficiently in nodejs if you are using mongodb as database.

The idealogies which were kept in mind are:

  • Simple and light library
  • Easy to use

If you want to learn how to use pkmongo library, please see this sample application https://github.com/pankaj805/BasicNodeApp

API Documentation

create

MongoHelper.create(collectionName<String>, data<Object>)
This function is used to insert a record into the given collection.
It takes two arguments, the first being the collection name and the second being the data to be inserted.

update

MongoHelper.update(collectionName<String>, criteria<Object>, dataToUpdate<Object>)
This function is used to update a record in a given collection based on certain criteria.
It takes three arguments, the first being the collection name and the second being conditional criteria and the third being the data to be inserted.

findOneByCriteria

MongoHelper.findOneByCriteria(collectionName, criteria<Object>)
This function is used to find a particular record based on a criteria.
It takes two arguments, the first being the collection name and the second being the conditional criteria. It returns only one record.

findByCriteria

MongoHelper.findByCriteria(collectionName<String>, criteria<Object>)
This function is used to find some records based on a criteria.
It takes two arguments, the first being the collection name and the second being the conditional criteria. It returns more than one record if available.

deleteByCriteria

MongoHelper.deleteByCriteria(collectionName<String>, criteria<Object>)
This function is used to delete a record based on some criteria.
It takes two arguments, the first being the collection name and the second being the conditional criteria. It deletes only one record

findAndProject

MongoHelper.findAndProject(collectionName<String>, criteria<Object>, projectionFields[Array])
This function is used to find records based on certain criteria and project specific fields in the result set.
It takes three arguments, the first being the collection name, the second being the conditional criteria and the third being the fields which you want to be projected in the resultset. It returns more than one record if available.

findCountByCriteria

MongoHelper.findCountByCriteria(collectionName<String>, criteria<Object>)
This function is used to calculate the count of records based on certain search criteria.
It takes two arguments, the first being the collection name and the second being the conditional criteria. It returns the count of the result set.

addToSet

MongoHelper.addToSet(collectionName<String>, criteria<Object>, fieldName<String>, valueToAdd<Any>
This function is to push a value to an array of values of a particular field in the collection.
It takes four arguments, the first being the collection name, the second being the conditional criteria, the third being the field name where you have to push the value and the fourth being the value to be pushed.

pullFromSet

MongoHelper.pullFromSet(collectionName<String>, criteria<Object>, fieldName<String>, valueToRemove<Any>
This function is to delete/pull a value from an array of values of a particular field in the collection.
It takes four arguments, the first being the collection name, the second being the conditional criteria, the third being the field name where you want the value to be deleted and fourth being the value to be pulled/deleted.

incrementField

MongoHelper.incrementField(collectionName<String>, criteria<Object>,fieldToIncrement<String>)
This function is used to increment the value of a particular field by 1 in a given collection based on certain criteria
It takes three arguments, the first being the collection name and the second being the conditional criteria and the third being the field which needs to be incremented.

decrementField

MongoHelper.decrementField(collectionName<String>, criteria<Object>,fieldToIncrement<String>)
This function is used to decrement the value of a particular field by 1 in a given collection based on certain criteria
It takes three arguments, the first being the collection name and the second being the conditional criteria and the third being the field which needs to be decremented.