我想获取特定于本地字段的projectId虎钳的数量。例如,我有以下文档:
{
"_id" : ObjectId("5c0a4efa91b5021228681f7a"),
"projectId" : ObjectId("5c0a4083753a321c6c4ee024"),
"hours" : 8,
"__v" : 0
}
{
"_id" : ObjectId("5c0a4f4191b5021228681f7c"),
"projectId" : ObjectId("5c0a2a8897e71a0d28b910ac"),
"hours" : 6,
"__v" : 0
}
{
"_id" : ObjectId("5c0a4f4191b5021228681f7d"),
"projectId" : ObjectId("5c0a4083753a321c6c4ee024"),
"hours" : 2,
"__v" : 0
}
现在,我想获取projectId的小时字段计数等于 5c0a4083753a321c6c4ee024 ,即10。
可以使用$ lookup吗?