Reputation: 2101
my document looks like:
{
"_id" : ObjectId("579f205f20754ea8cc58e22e"),
"date" : ISODate("2016-08-01T10:11:00.000Z"),
"httpRequestData" : {"charset" : "null", "encoding" : "gzip, deflate"},
"status" : "normalized"
}
and I want to query it like: select some columns and apply a "where" clause specifying a "status and a date range".
So:
db.fingerprint.find({"status" : {"$ne" : "deprecated"}},
{ "date": 1, 'httpRequestData.ipAdress': 1},
{"date" : { $gte : new ISODate("2016-08-30") }})
But it doesn't seem to select the time range I want, showing records from dates before the one I stated.
What am I doing wrong?
Upvotes: 0
Views: 133
Reputation: 103365
You are placing the date range query incorrectly; you should put it in the same document/object as your status query i.e.
db.fingerprint.find(
{
"status": { "$ne": "deprecated" },
"date": { "$gte": new ISODate("2016-08-30") }
},
{ "date": 1, "httpRequestData.ipAdress": 1 },
)
Upvotes: 1