When receiving input from the front-end, it looks like this:
{
"options":[
{
"optionId":"5ebbe0f56b197f36fc472168"
},
{
"optionId":"5ebbe1aa6b197f36fc47216e"
}
]
}
The goal is to filter the data in a way that results in an array of objects containing both of these IDs. Here is the data structure to search through:
"answersArray" : [
{
"_id" : ObjectId("5ede62f6a6979e5128bb89ba"),
"questionId" : ObjectId("5ebbe00e6b197f36fc472161"),
"answerId" : ObjectId("5ebbe00e6b197f36fc472162")
},
{
"_id" : ObjectId("5ede62f6a6979e5128bb89b9"),
"questionId" : ObjectId("5ebbe0f56b197f36fc472168"),
"answerId" : ObjectId("5ebbe0f56b197f36fc472169")
},
{
"_id" : ObjectId("5ede62f6a6979e5128bb89b8"),
"questionId" : ObjectId("5ebbe1aa6b197f36fc47216e"),
"answerId" : ObjectId("5ebbe1aa6b197f36fc47216f")
}
],
"answersArray" : [
{
"_id" : ObjectId("5ede620ea6979e5128bb89b5"),
"questionId" : ObjectId("5ebbd4e76b197f36fc47211e"),
"answerId" : ObjectId("5ebbd4e76b197f36fc47211f")
},
{
"_id" : ObjectId("5ede620ea6979e5128bb89b4"),
"questionId" : ObjectId("5ebbd5516b197f36fc472120"),
"answerId" : ObjectId("5ebbd5516b197f36fc472121")
},
{
"_id" : ObjectId("5ede62f6a6979e5128bb89b8"),
"questionId" : ObjectId("5ebbe1aa6b197f36fc47216e"),
"answerId" : ObjectId("5ebbe1aa6b197f36fc47216f")
},
]
The expected answer should be:
"answersArray" : [
{
"_id" : ObjectId("5ede62f6a6979e5128bb89ba"),
"questionId" : ObjectId("5ebbe00e6b197f36fc472161"),
"answerId" : ObjectId("5ebbe00e6b197f36fc472162")
},
{
"_id" : ObjectId("5ede62f6a6979e5128bb89b9"),
"questionId" : ObjectId("5ebbe0f56b197f36fc472168"),
"answerId" : ObjectId("5ebbe0f56b197f36fc472169")
},
{
"_id" : ObjectId("5ede62f6a6979e5128bb89b8"),
"questionId" : ObjectId("5ebbe1aa6b197f36fc47216e"),
"answerId" : ObjectId("5ebbe1aa6b197f36fc47216f")
}
],
Any suggestions on how to achieve this filtering?