29 lines
703 B
Go
29 lines
703 B
Go
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
|
|
}
|