Skip to content

Instantly share code, notes, and snippets.

@savokiss
Created February 17, 2017 03:05
Show Gist options
  • Save savokiss/83bc032437a50d1cdfc8f1b40c581358 to your computer and use it in GitHub Desktop.
Save savokiss/83bc032437a50d1cdfc8f1b40c581358 to your computer and use it in GitHub Desktop.
mongodb findProject.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
}
},{
name: 1,
age: 1,
_id: 0
}).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