Created
February 17, 2017 03:06
-
-
Save savokiss/f663d7df47da158ca3fe8c0a22b4c5be to your computer and use it in GitHub Desktop.
mongodb count.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongo = require('mongodb').MongoClient; | |
var age = process.argv[2]; | |
var url = 'mongodb://localhost:27017/learnyoumongo'; | |
mongo.connect(url, function(err, db){ | |
if(err) throw err; | |
var parrots = db.collection('parrots'); | |
parrots.count({ | |
age: { | |
$gt: +age | |
} | |
}, function(err, count){ | |
if (err) throw err; | |
console.log(count); | |
db.close(); | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment