【发布时间】:2021-09-23 09:21:43
【问题描述】:
我在 mongodb 数据库中有两个集合。一个 status 列很常见。我需要基于 status 列的集合中的 matched 和 unmatched count。 我写了一些代码,但它只获取匹配的计数。
db.properties.aggregate([
{
$lookup: {
from: "old_properties_data",
localField: "identifier",
foreignField: "identifier",
as: "col2docs"
}
},
{"$group" : {_id:"_id", count:{$sum:1}}}
])
【问题讨论】:
标签: mongodb mongodb-query lookup mongodb-lookup