混合时间戳和ISODates的mongodb查询
我有一个混合时间戳和ISODates的mongodb查询,mongodb,mongodb-query,isodate,Mongodb,Mongodb Query,Isodate,我有一个mongodb集合,其中包含同时包含ISODates和timestamp的文档,如下所示: doc = { "_id" : ObjectId(...), "updated" : 1445939778450, "delivered" : ISODate("2016-12-21T09:40:29.082Z") ... } db.my_collection.find({ $where : "this.updated > this.delivered" }
mongodb
集合,其中包含同时包含ISODates
和timestamp
的文档,如下所示:
doc = {
"_id" : ObjectId(...),
"updated" : 1445939778450,
"delivered" : ISODate("2016-12-21T09:40:29.082Z")
...
}
db.my_collection.find({ $where : "this.updated > this.delivered" })
如何使用$where比较更新的和交付的字段?这是一个很好的问题!:)
似乎mongodb
在使用$where
时会自动处理此转换,因此只需如下查询:
doc = {
"_id" : ObjectId(...),
"updated" : 1445939778450,
"delivered" : ISODate("2016-12-21T09:40:29.082Z")
...
}
db.my_collection.find({ $where : "this.updated > this.delivered" })
(如果有人可以指向有关此功能的文档,请添加)