ReservationRepo
No overview available.
Methods
Get()
@classmethod
def Get(
ctx: context.Context,
key: string
) - > *models.Reservation, error
Fetches a reservation by its unique key. Callers use this to retrieve details of a specific reservation.
Parameters
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context for the request, used for cancellation and deadlines. |
| key | string | The unique identifier for the reservation to retrieve. |
Returns
| Type | Description |
|---|---|
*models.Reservation, error | The reservation object if found, otherwise an error. |
Create()
@classmethod
def Create(
ctx: context.Context,
reservation: *models.Reservation
) - > error
Creates a new reservation in the repository. This method is used to persist a new reservation record.
Parameters
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context for the request, used for cancellation and deadlines. |
| reservation | *models.Reservation | The reservation object to be created. |
Returns
| Type | Description |
|---|---|
error | An error if the reservation could not be created, otherwise nil. |
UpdateIfExpiredOrOwned()
@classmethod
def UpdateIfExpiredOrOwned(
ctx: context.Context,
reservation: *models.Reservation,
now: time.Time
) - > error
Updates an existing reservation only if it is expired or currently owned by the provided reservation's owner. This ensures that reservations are updated under specific conditions.
Parameters
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context for the request, used for cancellation and deadlines. |
| reservation | *models.Reservation | The reservation object containing the updated data and owner information. |
| now | time.Time | The current time, used to check if the reservation has expired. |
Returns
| Type | Description |
|---|---|
error | An error if the update fails or conditions are not met, otherwise nil. |
DeleteByKeyAndOwner()
@classmethod
def DeleteByKeyAndOwner(
ctx: context.Context,
key: string,
ownerID: string
) - > error
Deletes a reservation identified by its key and owner ID. This method ensures that only the owner can delete their reservation.
Parameters
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context for the request, used for cancellation and deadlines. |
| key | string | The unique identifier of the reservation to delete. |
| ownerID | string | The ID of the owner attempting to delete the reservation. |
Returns
| Type | Description |
|---|---|
error | An error if the deletion fails or the owner does not match, otherwise nil. |