craban/server/app/game.go

24 lines
546 B
Go
Raw Normal View History

package app
import (
"database/sql"
"git.ctrlz.es/mgdelacroix/craban/model"
)
func (a *App) CreateGame(name string, userID int) (*model.Game, error) {
return a.Store.Game().Create(name, userID)
}
func (a *App) AddMember(gameID, userID int, role string) (*model.GameMember, error) {
return a.Store.Game().AddMember(gameID, userID, role)
}
func (a *App) ListGamesForUser(userID int) ([]*model.Game, error) {
games, err := a.Store.Game().ListForUser(userID)
if err == sql.ErrNoRows {
return []*model.Game{}, nil
}
return games, err
}