我可以检查mongo中两个计数值之间的相等性吗?

时间:2017-08-09 08:19:28

标签: mongodb

是否可以检查$count的值是否等于一个查询中的内容?

类似的东西:

{
  count: {...} : $eq : 5
}

例如: 我管理一个民意调查网站,我想查询至少2个人积极回答的所有问题。我没有一个字段来容纳有多少人回答了我需要在一个对象数组上计算的问题,每个答案都有一个支柱,标记它是正面的(1)还是negetive(0)。

[
{questionId:1,
text:...,
answers: [{text, pos:1},{text, pos:0},{text, pos:0}....]},
{questionId:2,
text:...,
answers: [{text, pos:1},{text, pos:0},{text, pos:1}....]},
{questionId:3,
text:...,
answers: [{text, pos:0},{text, pos:1},{text, pos:1}....]},
{questionId:4,
text:...,
answers: [{text, pos:0},{text, pos:1},{text, pos:0}....]},
]

我期望的结果是:

[{questionId:2, ...}, {questionId:3, ...}]

0 个答案:

没有答案
相关问题