I have a player model in Go for Mongo and a Level model
type LevelModel struct {
Index int `json: "index" bson: "index"`
Time int64 `json: "time" bson: "time"`
}
type PlayerModel struct {
ID bson.ObjectId `json: "_id, omitempty" bson: "_id, omitempty"`
Score int64 `json: "score" bson: "score"`
Level []LevelModel `json: "level" bson: "level"`
}
How to update Level from PlayerModel if I have a PlayerModel instance (player pointer)? The player can play a new (not yet played) level (then insert) or have already played (just update if the time is less than already reached for this level).
source
share