add missing path property handling
This commit is contained in:
@@ -7,12 +7,13 @@ import (
|
||||
"hamster-tycoon/storage/model"
|
||||
)
|
||||
|
||||
func (db *DatabasePostgreSQL) GetAllCages() ([]*model.Cage, error) {
|
||||
func (db *DatabasePostgreSQL) GetAllCages(gameID string) ([]*model.Cage, error) {
|
||||
q := `
|
||||
SELECT c.id, created_at, updated_at, game_id
|
||||
FROM public.Cage c
|
||||
WHERE c.game_id=$1
|
||||
`
|
||||
rows, err := db.session.Query(q)
|
||||
rows, err := db.session.Query(q, gameID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -33,13 +34,13 @@ func (db *DatabasePostgreSQL) GetAllCages() ([]*model.Cage, error) {
|
||||
return cages, nil
|
||||
}
|
||||
|
||||
func (db *DatabasePostgreSQL) GetCageById(id string) (*model.Cage, error) {
|
||||
func (db *DatabasePostgreSQL) GetCageByID(gameID, cageID string) (*model.Cage, error) {
|
||||
q := `
|
||||
SELECT c.id, created_at, updated_at, game_id
|
||||
FROM public.Cage c
|
||||
WHERE c.id = $1
|
||||
WHERE c.game_id=$1 and c.id = $2
|
||||
`
|
||||
row := db.session.QueryRow(q, id)
|
||||
row := db.session.QueryRow(q, gameID, cageID)
|
||||
|
||||
game := model.Game{}
|
||||
cage := model.Cage{
|
||||
|
||||
Reference in New Issue
Block a user