Created
August 15, 2016 18:13
-
-
Save EIrwin/6659fff90065b0ae32ae34fdb9a078cb to your computer and use it in GitHub Desktop.
Get Requests by list of RequestIDs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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