猫鼬计数出现的多个字段和值

时间:2019-07-12 20:24:25

标签: mongodb mongoose

我无法执行正确的查询来计算出现多个值的次数。我的模式是这里的一个想法:

客户端架构:

{
firstname: String,
lastname: String,
city: String
}

代理模式:

{
firstname: String,
lastname: String,
network: String
}

任务模式:

{
deadline: Date,
agent: ObjectId,
missions: [{
 title: String,
 clients:[{
  client: ObjectId,
  visited: Boolean,
 }]
}]

}

我要退货的是{agent: "Chris Malon", visited: "sum of visited = true", not_visited: "sum of visited = false"}

实现此目标的正确方法是什么?谢谢

0 个答案:

没有答案