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

37 lines
713 B
Go
Raw Normal View History

2021-09-20 14:57:24 +02:00
package postgres
import (
"fmt"
"github.com/jmoiron/sqlx"
_ "github.com/lib/pq"
)
func NewStore(dataSourceName string) (*Store, error) {
db, err := sqlx.Open("postgres", dataSourceName)
if err != nil {
return nil, fmt.Errorf("error opening database %w", err)
}
if err := db.Ping(); err != nil {
return nil, fmt.Errorf("error connecting to database %w", err)
}
return &Store {
ServerStore: &ServerStore{DB: db},
2021-09-20 22:55:12 +02:00
RegionStore: &RegionStore{DB: db},
GamemodeStore: &GamemodeStore{DB: db},
2021-09-23 15:58:56 +02:00
FlagStore: &FlagStore{DB: db},
2021-09-20 14:57:24 +02:00
}, nil
}
type Store struct {
*ServerStore
2021-09-20 22:55:12 +02:00
*RegionStore
*GamemodeStore
2021-09-23 15:58:56 +02:00
*FlagStore
2021-09-20 14:57:24 +02:00
}