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
Philipp 9dae1ca401
Some checks failed
continuous-integration/drone/push Build is failing
seperated gamemodes into seprate tables
2021-09-22 14:12:49 +02:00

34 lines
659 B
Go

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},
RegionStore: &RegionStore{DB: db},
GamemodeStore: &GamemodeStore{DB: db},
}, nil
}
type Store struct {
*ServerStore
*RegionStore
*GamemodeStore
}