【发布时间】:2019-04-04 12:36:03
【问题描述】:
我有以下架构
{
f1: "test",
f2: "something",
type: "A",
date: "2018-11-01T00:00:00.000Z",
deleted: false
},
{
"f1": "check",
type: "B",
deleted: false
}
现在我想要的是获取所有数据,如果是type = "A", then add an extra condition to my match query, suppose compare its date with current date。
我目前的查询是:
db.getCollection('myCollection').aggregate([
{$match:{
{"deleted":false},
// I want to check if type is A then compare its date
}}
])
【问题讨论】:
标签: mongodb mongoose aggregation-framework