Skip to content

Instantly share code, notes, and snippets.

@yannick
Created September 11, 2013 13:43
Show Gist options
  • Select an option

  • Save yannick/6523809 to your computer and use it in GitHub Desktop.

Select an option

Save yannick/6523809 to your computer and use it in GitHub Desktop.
var MongoClient = require('mongodb').MongoClient
, format = require('util').format;
MongoClient.connect('mongodb://127.0.0.1:27017/ricardo-crawler-2', function(err, db) {
if(err) throw err;
var items = db.collection('items');
items.count(function(err, count) {
console.log(format("%s items", count));
});
items.find({sold: true}).count(function(err, count) {
console.log(format("%s items sold", count));
});
items.find({sold: false}).count(function(err, count) {
console.log(format("%s unsold", count));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment