大于整数的地方 - 水线/帆/蒙戈



我正在尝试在 Sails with Mongo 中做一个多重 where 语句,但我没有任何这样的运气

    var start = moment().subtract(30, 'days').unix();
    var end = moment().unix();
    console.log(start, end)
    Measurement.find()
    .where({
        user: jwt.decoded.id,
        and: [
          { timestamp: { ">=": start }},
          { timestamp: { "<=": end }}
        ],
    })
    .sort('timestamp DESC')
    .then((results) => {
        return res.view('dashboard', {title: 'MMOL', data: results, tab: 'dashboard', code: 90})
    })

例如,我的开始时间是1507410695,结束时间是1510006295。

在我的收藏中,我有大约 40 条记录介于这些日期之间,它们的结构如下:

{
    "_id": {
        "$oid": "5a0083aa25b9c9bb37b5fc5d"
    },
    "timestamp": 1509916500,
    "blood": 9,
    "carb": 20,
    "calorie": 230,
    "insulin": 2,
    "notes": null,
    "user": {
        "$oid": "59fcced3c40317c657878b5c"
    },
    "createdAt": {
        "$date": "2017-11-06T15:45:46.572Z"
    },
    "updatedAt": {
        "$date": "2017-11-06T22:05:35.270Z"
    }
}

我根本无法得到任何结果。 据我所知,我这样做是正确的。如果我删除 and 语句,我会毫无问题地获得所有结果。有什么想法吗?

与其使用

and ,不如使用

user: jwt.decoded.id, 
timestamp: { 
   '>=' : start, 
   '<=' : end 
}

最新更新