大于整数的地方 - Waterline/Sails/Mongo

Where greater than integer - Waterline/Sails/Mongo

我正在尝试使用 Mongo 在 Sails 中执行多个 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。

在我的 Collection 中,我有大约 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 
}