I am having difficulty converting a MongoDB query to mgo bson. The Mongo record schema is as shown below. I want to find records that have topics with label "Education" and "Students".
db.questions.insert
(
{
"_id" : ObjectId("5cb4048478163fa3c9726fdf"),
"questionText" : "why?",
"createdOn" : new Date(),
"createdBy": user1,
"topics" : [
{
"label": "Education",
},
{
"label": "Life and Living",
},
{
"label": "Students"
}
]
}
)
Using Robo 3T, the query looks like this:
db.questions.find({$and : [
{"topics": {"label": "Students"}},
{"topics": {"label": "Education"}}
]})
I am having trouble modeling this with MGO. Currently, have tried this:
map[$and:[
map[topics:map[label:students]]
map[topics:map[label:life and living]]
]]
and this
map[topics:map[$and:[
map[label:students]
map[label:life and living]
]]]