Cleaning up our make reservation page and testing everything
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user