I have an mongoDB object like
{
"courseName" : "AI",
"user" : ObjectId("6087dc4c2ba7a828363c9fca"),
"questions" : [
{
"optionsSet" : [
{
"value" : "A",
},
{
"value" : "B",
}
],
"topics" : ["b", "c", "a"],
"createdAt" : "2021-07-07T18:41:18.971Z"
},
{
"optionsSet" : [
{
"value" : "C",
},
{
"value" : "D",
}
],
"topics" : ["c"],
"createdAt" : "2021-08-07T18:41:18.971Z
},
{
"optionsSet" : [
{
"value" : "CC",
},
{
"value" : "DD",
}
],
"topics" : ["b"],
"createdAt" : "2021-08-07T18:41:30.971Z"
}
]
}
Sometime I have to use only match the courseName and user only.
Another time I have to query with the courseName user and topics
where topics which at least match one topic. How can i handle this process?
When I pass input as courseName, user and topics ["b"]. I deselected user and optionsSet in return output. My expected out put will be :
{
"courseName" : "AI",
"questions" : [
{
"topics" : ["b", "c", "a"],
},
{
"topics" : ["b"],
}
]
}
Is this possible?