Skip to content

Instantly share code, notes, and snippets.

@savokiss
Created February 17, 2017 01:49
Show Gist options
  • Save savokiss/77a125579c6e628e9ffac80b77ff4859 to your computer and use it in GitHub Desktop.
Save savokiss/77a125579c6e628e9ffac80b77ff4859 to your computer and use it in GitHub Desktop.
mongodb find.js
var mongo = require('mongodb').MongoClient;
var url = 'mongodb://localhost:27017/learnyoumongo';
var age = process.argv[2];
mongo.connect(url,function(err, db){
if(err) throw err;
var parrots = db.collection('parrots');
parrots.find({
age:{
$gt: +age
}
}).toArray(function(err, docs){
if(err) throw err;
console.log(docs);
db.close();
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment