如何编写查询开始日期和结束日期,outdoor_tracking
有列tracking_created_date
,我希望过滤我的所有记录开始日期tracking_created_date
和结束日期tracking_created_date
在跟踪列的基础上过滤所有记录,请帮我这个。感谢
我想过滤我的数据tracking_created_date
export function getdatewise(req, res) {
return Campaign.find({$or: [{ "assets.outdoor_tracking.tracking_created_date" : {"$gte":new Date(), "$lte": new Date()} }] }).exec()
.then(handleEntityNotFound(res))
.then(respondWithResult(res))
.catch(handleError(res));
}
Mongodb数据
{
"_id" : ObjectId("5a266f16663eb423d86937c9"),
"company_id" : ObjectId("5a102c4b6b8d184b0897d4fc"),
"brand_id" : ObjectId("5a102c726b8d184b0897d4ff"),
"companyname" : "abc",
"assets" : [
{
"_id" : ObjectId("5a1ffdb68a624329a8196ec5"),
"city" : "abc",
"region" : "abc",
"location" : "abc",
"outdoor_tracking" : [
{
"latitude" : "1.192618",
"longitude" : "1.191406",
"_id" : ObjectId("5a266fadd5a1fe0dc053faee"),
"updated_date" : ISODate("2017-12-05T10:06:37.611Z"),
"tracking_created_date" : ISODate("2017-12-05T10:06:37.611Z"),
"comment" : "vfff"
}
]
}
],"__v" : 1
}
答案 0 :(得分:0)
最终查询创建:
export function getdatewise(req, res) {
return Campaign.find({$or: [{ "assets.outdoor_tracking.tracking_created_date" : {$gte:new Date("2015-04-14T23:59:59Z"),$lte: new Date("2017-12-15T23:59:59Z")} }] }).exec()
.then(handleEntityNotFound(res))
.then(respondWithResult(res))
.catch(handleError(res));
}