Is it possible to check if a value of $count
is equal to something in one query ?
something like:
{
count: {...} : $eq : 5
}
eg: I manage a poll site and I want to query for all the questions that were answered positivly by at least 2 people. I dont have a field to hold how many people answered a question I need to $count for it on an array of objects, each answer holds a prop that marks if the it's positive (1) or 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}....]},
]
the result I expect is:
[{questionId:2, ...}, {questionId:3, ...}]