Skip to content

Instantly share code, notes, and snippets.

@EIrwin
Created August 15, 2016 18:13
Show Gist options
  • Save EIrwin/6659fff90065b0ae32ae34fdb9a078cb to your computer and use it in GitHub Desktop.
Save EIrwin/6659fff90065b0ae32ae34fdb9a078cb to your computer and use it in GitHub Desktop.
Get Requests by list of RequestIDs
var groups []Group
err = c.Find(bson.M{"requests": bson.M{"$elemMatch": bson.M{"_id": bson.M{"$in": requestIDs}}}}).All(&groups)
if err != nil {
log.Println(err)
return requests, err
}
for _, group := range groups {
for _, request := range group.Requests {
for _, id := range requestIDs {
if id == request.ID {
requests = append(requests, request)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment