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

mpill

v0.5.1

Published

MoNoApps MongoDB Pill

Downloads

29

Readme

MPill

Coding apps without to be worried about data models.

Single model instance

var MPill = require('mpill').MPill;
var url = 'mongodb://127.0.0.1/mpill';
users = new MPill('users', url);

Multiple models at once

models.js

var MPill = require('../mpill.js').MPill;

var colls = ['users','groups','roles','tasks'];
var url   = 'mongodb://127.0.0.1/mydb';

// exports each collection
for(var i in colls){
	module.exports[colls[i]] = new MPill(colls[i], url);
}

userController.js (let's said this is for express route)

var models = require('./models');
var Users = {};

Users.List = function(req, res){
  models.users.FindOne({'email': '[email protected]'}, function(err, rrunner){
    if(err){ return res.status(500); }
    var query = { user_id: rrunner._id, label: 'open' };
      models.tasks.Find(query, function(err, toDo){
        if(err){ return res.status(500); }
        res.json({
          user: rrunner,
          tasks: toDo
        });
      });
    });
};
...
module.exports.Users = Users;

API reference

'Generic methods'
model.Connect(cb)
model.DropDB(cb)

'Common methods'
model.Insert(doc, cb)
model.Update(query, doc, concern, cb)
model.Remove(query, cb)
model.Find(query, cb, project, options, limit, sort)
model.FindOne(query, cb)
model.CreateIndex(query, cb)
model.DropCollection(query, cb)
model.DropIndex(query, cb)
model.CreateCollection(cb)
model.Count(query, cb)
model.Aggregate(query, cb)

'Special methods'
model.FindByObjectId(query, key, cb)
model.UpdateByObjectId(query, doc, key, cb)
model.RemoveByObjectId(query, key, cb)
model.parseOID(value, cb)

Test with tpill

Running CRUD sample

npm install
// mongod --dbpath $HOME/data/mpill &
node example/crud.js

Results:

✓ CreateCollection
✓ DropCollection
✓ Insert
✓ Update
✓ FindOne
✓ FindByObjectId
✓ UpdateByObjectId
✓ RemoveByObjectId
✓ Count
✓ DropDB

Statistics: {"pass":10,"fail":0,"warn":0}

RESTful API sample

Clone deck tool to see a restify implementation.

Test with mocha

Keeps definded functions.

mocha
18 passing (20ms)

Code quality with gulp-jshint

npm install gulp
npm install gulp-jshint
gulp

About concern

Full api doc: http://docs.mongodb.org/manual/reference/write-concern/

//Sample with concern
var concern = {w:1}; //Use primary node server

Changelog:

v0.5.1

  • Add Aggregation framework queries.
  • Add tests for mongo v3

v0.5.0

  • Stable version for common queries