I am using the mgo.v2 driver with the latest version of MongoDB installed. My document structure is defined like this:
type gameTemplate struct {
ID bson.ObjectId `bson:"_id" json:"id"`
GameCode string `bson:"gamecode" json:"gamecode"`
Players []player `bson:"players" json:"players"`
}
type player struct {
PlayerID bson.ObjectId `bson:"playerid" json:"playerid"`
Username string `bson:"username" json:"username"`
Level int `bson:"level" json:"level"`
}
How would I go about getting a list of usernames in a particular game (Defined by gamecode
)?
Is there a way to get the size of the array and iterate through the elements, or is there a preferred method?