Lets say I have the following data in a Groups
collection in MongoDB
[
{
“Group”: {
“_id”: 1,
“Requests”: [
{
“_id”:1,
“name”:”Request A”
}.
{
“_id”:2,
“name”:”Request B”
}
]
}
},
{
“Group”: {
“_id”: 2,
“Requests”: [
{
“_id”:3,
“name”:”Request C”
}.
{
“_id”:4,
“name”:”Request D”
}
]
}
}
]
Also, lets say I have the following function
func GetRequests(requestIDs []string) (Request[] error){
//NEED TO IMPLEMENT W/ MGO
}
Is there a way to use the aggregation pipeline (or not if its not needed) to return just a projection of the requests matching requestIDs
?
For example
Sample input reflecting requestIds
[1,2,4]
Sample output from mgo
aggregation/query
[
{
“_id”:1,
“name”:”Request A”
},
{
“_id”:2,
“name”:”Request B”
},
{
“_id”:4,
“name”:”Request D”
}
]