e.g:
In Mongodb, the collection reports has following documents:
db.reports.find()
{ "_id" : ObjectId("4da6992090d211cc097fbb02"), "type" : 0,
"datetime" : "2011-03-30", "amount" : 50760 } { "_id" :
ObjectId("4da6992c90d211cc097fbb03"), "type" : 0, "datetime" :
"2011-03-31", "amount" : 45990 } { "_id" :
ObjectId("4da6993290d211cc097fbb04"), "type" : 0, "datetime" :
"2011-04-01", "amount" : 47430 } { "_id" :
ObjectId("4da6993b90d211cc097fbb05"), "type" : 0, "datetime" :
"2011-04-02", "amount" : 49140 } { "_id" :
ObjectId("4da6994390d211cc097fbb06"), "type" : 0, "datetime" :
"2011-04-03", "amount" : 37260 }
I want to do query using "datetime" in mongoose, so i use the
following code to do it:
var Reports = mongoose.model('Reports');
Reports.find({'datetime': {$gte: '2011-03-30', $lte: '2011-04-01'}},
['type', 'datetime', 'amount']).sort([['datetime']], 1).run (
function(err, reports) { if (err) { console.log("load reports
failed"); } loadCallback(req, res, reports); });
But i can't work!