21 lines
447 B
Go
21 lines
447 B
Go
|
package postgres
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
|
||
|
"git.snrd.de/Spaenny/steamServer"
|
||
|
"github.com/jmoiron/sqlx"
|
||
|
)
|
||
|
|
||
|
type RegionStore struct {
|
||
|
*sqlx.DB
|
||
|
}
|
||
|
|
||
|
func (s *RegionStore) Region(name string) (steamServer.Region, error) {
|
||
|
var r steamServer.Region
|
||
|
if err := s.Get(&r, `SELECT * FROM regions WHERE name = $1`, name); err != nil {
|
||
|
return steamServer.Region{}, fmt.Errorf("error getting region id: %w", err)
|
||
|
}
|
||
|
return r, nil
|
||
|
}
|