在mongoose中查询和按date过滤

我有这个级别的mongoose文件 在这里输入图像描述

我试图做一个filter来填充位于某个date范围内的位置的几何graphics。

我尝试这样的事情:

.populate('geometries', null, { 'locations.properties.timeStamp': { $gt: startDate, $lt: endDate }}) .exec(function(err, item) { //some code } 

像这样:

  .populate('geometries') .where({ 'locations.properties.timeStamp': { $gt: startDate, $lt: endDate }}*/) .exec(function(err, item) { //some code } 

有了这些查询,我无法访问时间戳进行比较,结果为空或未定义。

编辑1:

variablesstartDate和endDate来自于angulars控制器的url,它们是这样定义的:

  var deductDate = new Date(endDate); var startDate = deductDate.setDate(deductDate.getDate()-1); Item.currentDay($stateParams.epc, url, { groupBy: '1d', endDate: moment(endDate).format(), startDate: moment(startDate).format('YYYY-MM-DD') + "T23:59:59" }); 

在API中,处理它的GETpath是:

  handler: function(request, reply) { var startDate = request.query.startDate; var endDate = request.query.endDate; Item.findById(request.params.id) .populate('geometries', null, { 'locations.properties.timeStamp': { $gt: startDate, $lt: endDate }}) .exec(function(err, item) { if (err) { reply(err); } else { reply(item); } }); } 

尝试做到这一点:

 .populate({ path: 'geometries', match: { 'locations.properties.timeStamp': { $gt: startDate, $lt: endDate }}, }).exec() 

从关于查询条件和其他选项的mongoose文档中提取( http://mongoosejs.com/docs/populate.html

做这个:

  var startDate = new Date(request.query.startDate); var endDate = new Date(request.query.endDate);