This repository has been archived on 2024-05-18. You can view files and clone it, but cannot push or open issues or pull requests.
steamServer/postgres/gamemode_store.go

30 lines
770 B
Go
Raw Normal View History

package postgres
import (
"fmt"
"git.snrd.de/Spaenny/steamServer"
"github.com/jmoiron/sqlx"
)
type GamemodeStore struct {
*sqlx.DB
}
func (s *GamemodeStore) Gamemode(name string) (steamServer.Gamemode, error) {
var g steamServer.Gamemode
if err := s.Get(&g, `SELECT * FROM gamemodes WHERE name = $1`, name); err != nil {
return steamServer.Gamemode{}, fmt.Errorf("error getting gamemode id: %w", err)
}
return g, nil
}
func (s *GamemodeStore) Gamemodes() ([]steamServer.Gamemode, error) {
var gg []steamServer.Gamemode
var query = `SELECT * FROM gamemodes ORDER BY name ASC`
if err := s.Select(&gg, query); err != nil {
return []steamServer.Gamemode{}, fmt.Errorf("error gettings servers: %w", err)
}
return gg, nil
}