Right now I am doing Learn MongoDB exercise 3
here is my code
var mongo = require('mongodb').MongoClient;
var path ="mongodb://localhost:27017/learnyoumongo";
mongo.connect(path,function(err,db){
if(err){
return err;
}
if(db){
var collection = db.collection('parrots');
collection.find({age:{$gt:3}}).toArray(function(err,document){
if(err){
return err;
}
console.log(document);
})
db.close();
}
})
and it show me the exact value i want to see
[ { _id: 5866ea9fb1a11e170a51ef53, name: 'Jenny', age: 10 } ]
but if i change the line
collection.find({age:{$gt:3}}).toArray(function(err,document){
into
collection.find({age:{$gt:process.argv[2]}}).toArray(function(err,document){
it shows
[]
but when I console.log(process.argv[2])
and it shows me 3
.
Can’t fig out why process.argv[2] not working insted of value 3.