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/flag_store.go

30 lines
703 B
Go
Raw Normal View History

2021-09-23 15:58:56 +02:00
package postgres
import (
"fmt"
"git.snrd.de/Spaenny/steamServer"
"github.com/jmoiron/sqlx"
)
type FlagStore struct {
*sqlx.DB
}
func (s *FlagStore) Flag(server_ip string) (steamServer.Flag, error) {
var f steamServer.Flag
if err := s.Get(&f, `SELECT * FROM flags WHERE name = $1`, server_ip); err != nil {
return steamServer.Flag{}, fmt.Errorf("error getting flag id: %w", err)
}
return f, nil
}
func (s *FlagStore) Flags() ([]steamServer.Flag, error) {
var ff []steamServer.Flag
var query = `SELECT * FROM flags`
if err := s.Select(&ff, query); err != nil {
return []steamServer.Flag{}, fmt.Errorf("error gettings flag: %w", err)
}
return ff, nil
}