func (m *gameRepo) UpdateGame(game *apipb.Game) error { c := m.driver.Session.DB("").C(GameCollection) game.LastUpdated = millisecondsNow() ga := &modelpb.Game{} ga.From(game) return toOtsimoError(c.UpdateId(ga.Id, bson.M{"$set": ga})) }
func (m *gameRepo) CreateGame(game *apipb.Game) error { if game.UniqueName == "" { return models.ErrorInvalidUniqueName } _, err := m.GetGameWithUniqueId(game.UniqueName) if err != models.ErrorNotFound { return models.ErrorUniqueNameExists } c := m.driver.Session.DB("").C(GameCollection) game.CreatedAt = millisecondsNow() game.LastUpdated = millisecondsNow() ga := &modelpb.Game{} ga.From(game) return toOtsimoError(c.Insert(ga)) }