Created
February 17, 2017 03:05
-
-
Save savokiss/83bc032437a50d1cdfc8f1b40c581358 to your computer and use it in GitHub Desktop.
mongodb findProject.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 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