Can get all the reservations of a given accommodation
This commit is contained in:
@ -1,9 +1,20 @@
|
||||
use crate::connections::db_connection;
|
||||
use crate::models::{AccommodationReservation, FamilyID};
|
||||
use crate::models::{AccommodationID, AccommodationReservation, FamilyID};
|
||||
use crate::schema::accommodations_reservations;
|
||||
use diesel::prelude::*;
|
||||
|
||||
/// Get all the accommodations reservations of a family
|
||||
/// Get all the reservations of an accommodation
|
||||
pub async fn get_all_of_accommodation(
|
||||
id: AccommodationID,
|
||||
) -> anyhow::Result<Vec<AccommodationReservation>> {
|
||||
db_connection::execute(|conn| {
|
||||
accommodations_reservations::table
|
||||
.filter(accommodations_reservations::dsl::accommodation_id.eq(id.0))
|
||||
.get_results(conn)
|
||||
})
|
||||
}
|
||||
|
||||
/// Get all the reservations of a family
|
||||
pub async fn get_all_of_family(id: FamilyID) -> anyhow::Result<Vec<AccommodationReservation>> {
|
||||
db_connection::execute(|conn| {
|
||||
accommodations_reservations::table
|
||||
|
Reference in New Issue
Block a user