I am fetching array result by applying query stored inside MONGODB. I am trying to fetch score:1's questionId only I am trying {'quiz.score':1} or {quiz:{$eq:{score:1}}}, but it return all questionId which score is 0 and 1
This is node js code
function(){
childQuizInfo.find({quiz:{$eq:{score:1}}},function(err,question){
if(err) return next(err);
res.send(question);
});
}
This is question id schema
quiz: {type: Array,
questionId: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Question',
index: true
},
score: { type: Number },
time: { type: String }
}
This is stored result inside mongodb
"quiz" : [
{
"time" : "2016-09-07T08:04:30.316Z",
"score" : 1,
"questionId" : "57ce608e2a0d6cad8c48ef8f"
},
{
"time" : "2016-09-07T08:06:35.399Z",
"score" : 0,
"questionId" : "57ce608e2a0d6cad8c48ef90"
},
{
"time" : "2016-09-07T08:06:49.296Z",
"score" : 1,
"questionId" : "57ce608e2a0d6cad8c48ef91"
},
{
"time" : "2016-09-07T08:06:56.699Z",
"score" : 0,
"questionId" : "57ce608e2a0d6cad8c48ef92"
},
{
"time" : "2016-09-07T08:07:00.660Z",
"score" : 1,
"questionId" : "57ce608e2a0d6cad8c48ef93"
}
I need a query so that it return only questionId which score is 1 in response.
The output I get
{
"message": "unknown top level operator: $eq"
}