record meals that were added to list, allow delete with ingredients
This commit is contained in:
+27
-2
@@ -2,8 +2,8 @@ use async_trait::async_trait;
|
||||
use sqlx::SqliteConnection;
|
||||
|
||||
use crate::domain::{
|
||||
Category, DomainResult, GroceryList, Item, Meal, MealCategory, MealIngredient, Passkey,
|
||||
PresenceUser, SessionUser, User,
|
||||
Category, DomainResult, GroceryList, Item, ListMeal, Meal, MealCategory, MealIngredient,
|
||||
Passkey, PresenceUser, SessionUser, User,
|
||||
};
|
||||
|
||||
/// Repositories take `&mut SqliteConnection` (which a `Transaction` derefs to),
|
||||
@@ -113,6 +113,9 @@ pub struct NewItem {
|
||||
pub quantity: String,
|
||||
pub note: String,
|
||||
pub category_id: Option<i64>,
|
||||
/// When set, links this item to the `list_meals` row it came from, so the
|
||||
/// item is removed together with that meal instance.
|
||||
pub list_meal_id: Option<i64>,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
@@ -158,6 +161,28 @@ pub trait ItemRepository: Send + Sync {
|
||||
) -> DomainResult<i64>;
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait ListMealRepository: Send + Sync {
|
||||
async fn list_meals(
|
||||
&self,
|
||||
txn: &mut SqliteConnection,
|
||||
list_id: i64,
|
||||
) -> DomainResult<Vec<ListMeal>>;
|
||||
async fn add_meal(
|
||||
&self,
|
||||
txn: &mut SqliteConnection,
|
||||
list_id: i64,
|
||||
meal_id: i64,
|
||||
name: String,
|
||||
) -> DomainResult<i64>;
|
||||
async fn remove_meal(
|
||||
&self,
|
||||
txn: &mut SqliteConnection,
|
||||
list_id: i64,
|
||||
list_meal_id: i64,
|
||||
) -> DomainResult<i64>;
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait InvitationRepository: Send + Sync {
|
||||
async fn create_invitation(
|
||||
|
||||
Reference in New Issue
Block a user