Cleaning up our make reservation page and testing everything

This commit is contained in:
2024-07-10 22:34:27 +02:00
parent 5a646a2b27
commit 95cddfc950
4 changed files with 56 additions and 20 deletions

View File

@ -126,3 +126,23 @@ func (m *postgresDBRepo) SearchAvailabilityForAllRooms(start, end time.Time) ([]
return rooms, nil
}
// GetRoomById gets a room by id
func (m *postgresDBRepo) GetRoomById(id int) (models.Room, error) {
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
var room models.Room
stmt := `select
id, room_name, created_at, updated_at
from
rooms
where id = $1`
row := m.DB.QueryRowContext(ctx, stmt, id)
err := row.Scan(&room.ID, &room.RoomName, &room.CreatedAt, &room.UpdatedAt)
if err != nil {
return room, err
}
return room, nil
}