【发布时间】:2023-02-16 18:55:50
【问题描述】:
我有一个查询,其中我使用开始日期和结束日期获取数据。它工作得很好。现在我想使用聚合在我的开始日期中添加 7 天,并希望获取开始日期 + 7 添加天的数据。我试过下面的代码但没有成功
{
$match: {
publishedAt: {
$lt: new Date(startDate),
$gte: new Date(endDate),
},
},
},
{
$set: {
publishedAt: {
$add: [new Date(startDate), 1000 * 60 * 60 * 24],
},
},
},
【问题讨论】:
标签: mongodb mongodb-query aggregation-framework aggregation nosql-aggregation