无法获取比日期更近的条目

Can't get entries more recent than date

本文关键字:日期 获取      更新时间:2023-09-26

我在节点上使用MongoDB和Monk很陌生,到目前为止我真的很喜欢它。 但是,直到我尝试进行查询,该查询将返回日期比我在查询中给出的日期更近的每个条目:

collection.find({date: {$gt: new Date(lastClear)}, {fields: _id:0}, function (e, data) {
    // data is empty, e is null
    console.log(e, data);
});

它应该返回几个条目,但它没有,我做错了什么?

编辑:我存储这种条目:

{
    _id: 507f1f77bcf86cd799439011,
   postuniqid: 0123456789,
   date: new Date("Fri Jan 23 2015 21:18:51 GMT+0100 (CET)"),
   author: 3,
   message: 'foo'
}

最后,lastClear 是一个日期对象,至于我的测试,它等于新的日期("星期三 Jan 21 2015 23:45:43 GMT+0100 (CET)")。

我没有使用Monk,而是决定使用默认的MongoDB驱动程序。我不明白为什么,但修饰符在我的数据库或集合上不再适用于 Monk。默认驱动程序的工作方式类似于超级按钮。