{
"_id": "5f6b45ad73cac785f0e7504c",
"user_id": "zzzz",
"survey_id": "40",
"questionList": [
{
"isDelete": 1,
"choices": [
{
"_id": "5f6b45ad73cac785f0e75068",
"name": "Choice1",
"value": "",
"score": 12,
"disqualifier": "true"
},
{
"_id": "5f6b45ad73cac785f0e75067",
"name": "choice2",
"value": "",
"score": 21,
"disqualifier": "true"
},
{
"_id": "5f6b45ad73cac785f0e75066",
"name": "choice3",
"value": "",
"score": 21,
"disqualifier": "false"
}
],
"_id": "5f6b45ad73cac785f0e75065",
"type": "mcq",
"name": "Multi Choice",
"value": "choice2",
"isMandatory": "true"
},
{
"isDelete": 0,
"choices": [
{
"_id": "5f6b45ad73cac785f0e75064",
"name": "option1",
"value": "",
"score": 12,
"disqualifier": "true"
},
{
"_id": "5f6b45ad73cac785f0e75063",
"name": "option2",
"value": "",
"score": 12,
"disqualifier": "false"
},
{
"_id": "5f6b45ad73cac785f0e75062",
"name": "option3",
"value": "",
"score": 33,
"disqualifier": "false"
}
],
"_id": "5f6b45ad73cac785f0e75061",
"type": "dropdown",
"name": "dropdown",
"value": "option2",
"isMandatory": "true"
}
我需要在survey_id 和user_id 上放置一个文件管理器,同时我需要选择QUESTIONLIST 中isDelete 为1 的所有对象。我确实尝试了很多东西,但似乎没有任何效果,或者我错了吗?这就是我所尝试的
await surveyfinal.find({$and:[{survey_id:req.body.survey_id},{user_id:req.body.user_id},{questionList:{$elemMatch:{isDelete:1}}}]})
await surveyfinal.find({user_id:req.body.user_id},{questionList:{$elemMatch:{isDelete:1}}} )
await surveyfinal.find({$and:[{user_id:req.body.user_id},{survey_id:req.body.survey_id},{"questionList.isDelete":1} ]})