【发布时间】:2020-03-08 11:51:32
【问题描述】:
我想创建一个视图和聚合,它使用 currentdate 应用日期过滤器。 在下面给出的示例中,我使用当前日期作为字符串并且工作正常,但我需要自动更新这些日期。
{
$and: [{
'promotionRange.start': {$lte: ISODate('2019-11-12')}
},
{
"promotionRange.end": {"$gte": ISODate('2019-11-12')}
}
]
}
我需要类似下面的代码
{
$and: [{
'promotionRange.start': {$lte: $currentDate}
},
{
"promotionRange.end": {"$gte": $currentDate}
}
]
}
这不起作用。并且 new Date() 也不起作用。
在聚合查询中使用当前日期有什么技巧吗?
【问题讨论】:
标签: mongodb mongodb-query aggregation-framework