蒙古:文件发现日期



这是我的mongodb数据库结构

coordinates : {
    lat : {type: Number},
    lon : {type: Number},
},
timeStamp :{type: Date} ,
accuracy :{type: Number},
deviceId : {type: Number},
deviceType : {type: String},
simId : {type: String}

我要查找日期的文件。

这是我从mongodb获取文档的查询

db.LocationInfoCollection.find({"deviceId":911441051085656,"timeStamp":{$gte:new Date("2015-09-07T12:56:44.000Z")}})

当我在mongodb上运行上面的查询时返回空白数组。

以上查询在mongo shell上完美运行。但在我的代码中没有。

mongo shell的输出

  {
    "timeStamp": "2015-09-08T12:31:24.000Z",
    "accuracy": 5,
    "deviceId": 911441051085656,
    "simId": "123456",
    "_id": "55eed361dfa115387dade3ce",
    "coordinates": {
      "lat": 20.998,
      "lon": 75.5667
    }
  }

如何获取上述日期查询的文档

你可能想在这里添加你的服务器代码,这样我们就能更好地理解你的破碎代码,这是你的server.js中的一些东西,你可能会说:

var app = require('express');
var Coordinate = require('/models/coordinate.js');
app.get('/api/coordinates/:id', function (req, res) {
    var targetId = req.params.id;
    Coordinate.findOne({_id: targetId}, function (err, review) {
        coordinates.date
        res.json(coordinates);
    })
});

让我知道这是否有帮助!

最新更新