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

monqodb

v0.4.7

Published

The mongodb Q promises wrapper that we use at Crowdference

Downloads

27

Readme

monqodb

The mongodb Q promises wrapper that we use at Crowdference

install

npm install --save monqodb

use

var monqodb = require('monqodb');

Connect to the database

Zeroconf connection

Currently when monqodb is called without options, it looks process.env for mongodb server's configuration:

host = MONGO_PORT_27017_TCP_ADDR || MONGO_ADDR || 'localhost'
port = MONGO_PORT_27017_TCP_PORT || MONGO_PORT || 27017
database = MONGO_PORT_27017_TCP_DATABASE || MONGO_DATABASE || 'test'
mongoName = MONGO_PORT_27017_TCP_NAME || MONGO_NAME || 'db'

That way it needs no configuration to connect to a docker container linked with the name mongo.

Custom connection.

If you need to configure the name of the database, (on the server or on the app); to configure other connection parameters like the poolSize or the writeConcern, or if you need to connect to more than one mongodb server or database, you need to pass an object with the configuration parameters.

Each key correspond with the in-application-name of the database, and his value has the options as documented mongo native docuentation

IMPORTANT The url must include the database name.

{
  db:{
    url:'mongodb://localhost/mydb',
    db:{
      w:1,
    },
    server:{
      poolSize:2,
      auto_reconnect:true
    },  
  },
  capped:{
    url:'mongodb://localhost/myCapped',
    db:{
      w:0,
    },
    server:{
      poolSize:1,
      auto_reconnect:true
    },
  }
}  

Connection promise

When you call monqodb to connect, it returns you a promise that will be fullfilled with [true, true, ...] when it has successfully connect to all databases.

require `monqodb`;
// ...
monqodb(options)
.then(function(){
  // YOU know you are connected
  server.listen(9000) 
})
.catch(function(err){
  console.log(err.stack);
  console.log(err)
});

Default Options

Default options are

{
  db:{
    w:1,
  },
  server:{
    poolSize:5,
    auto_reconnect:true
  },
}

You can change them before connect, at monqodb.____defaultOptions

Use

Your databases are members of monqodb and your collections members of those.

monqodb = require('monqodb');
// you have connected previously with foo and bar databases that have some collections
// so you can do
// monqodb.bar.oneCollectionfromBar.findOne(...).then(...)
// monqodb.foo.oneCollectionFromFoo.update(....).then(...)
// monqodb.bar.otherCollectionfromBar.insert(...).then(...)
// monqodb.foo.otherCollectionFromFoo.remove(...).then(...)

With monqodb you can use findOne, update, insert, remove, distinct, count, findAndModify, findAndRemove, geoNear, geoHaystackSearch in the Q promises way.

someCollection.someMethod(someOptions..., someCallback) becomes someCollection.someMethod(someOptions).then(someCallback)

On top of that, monqodb adds the toArray with which someCollection.find(someOptions).toArray(someCallback) becomes someCollection.toArray(someOptions).then(someCallback)

goodies

  • monqodb.ObjectID has ObjectID
  • monqodb.close() closes all monqodb connections.

using the mongo native api

you have all connections at the object monqodb.__connections, whose keys are the inAppDatabaseNames.

you have the original collection object at monqodb.{{inAppDatabaseName}}.{{collectionName}}.collection