[英]Mongodb aggregate match on dates
I'm running an aggregate query, and after a few projections, I end up with documents that look like 我正在运行汇总查询,经过一些预测,最终得到的文档看起来像
{ _id: 561bed08f8f068cd237a3dc1,
updateDate: Mon Oct 12 2015 11:25:28 GMT-0600 (MDT),
manager: 561bdd37f8f068cd237a3da2,
viewDate: Mon Oct 26 2015 09:02:57 GMT-0600 (MDT) }
Please note, those dates are the console formatted output, when inspected with mongohub, the dates look like new Date(<timestamp>)
. 请注意,这些日期是控制台格式的输出,当使用mongohub检查时,这些日期看起来像
new Date(<timestamp>)
。
I want to match documents where the updateDate
is greater than the viewDate
, so I have this match: 我想匹配
updateDate
大于viewDate
,所以我有这个匹配项:
$match: {
updateDate: { "$gt": new Date("$viewDate") }
}
However, it returns documents such as the one above, the updateDate
is on the 12th, and the viewDate
is on the 26th. 但是,它返回诸如上述文件之类的文档,
updateDate
在12号,而viewDate
在26号。
I have tried a few variations, with and without the new Date()
for example. 我尝试了一些变体,例如有无
new Date()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.