working on constraint design
This commit is contained in:
@@ -57,6 +57,7 @@ pub mod ingredients {
|
||||
use super::{SqliteConnection, schema};
|
||||
use super::diesel::prelude::*;
|
||||
|
||||
/// A wrapper of [`IngredientList`] with DB connection capacity.
|
||||
pub struct IngredientListManager<'a>(&'a SqliteConnection, IngredientList);
|
||||
|
||||
impl<'a> IngredientListManager<'a> {
|
||||
@@ -98,12 +99,9 @@ pub mod ingredients {
|
||||
fn find(conn: &SqliteConnection, name: &str) -> Option<Ingredient> {
|
||||
use self::schema::ingredients::dsl::*;
|
||||
|
||||
match ingredients.filter(alias.like(name))
|
||||
.first(conn)
|
||||
{
|
||||
Ok(ingdt) => Some(ingdt),
|
||||
Err(_) => None,
|
||||
}
|
||||
ingredients.filter(alias.like(name))
|
||||
.first(conn)
|
||||
.ok()
|
||||
}
|
||||
|
||||
fn create(conn: &SqliteConnection, name: &str) -> Result<i32,String> {
|
||||
|
||||
@@ -144,6 +144,12 @@ pub struct Recipe {
|
||||
pub preparation: String,
|
||||
}
|
||||
|
||||
impl PartialEq for Recipe {
|
||||
fn eq(&self, other: &Recipe) -> bool {
|
||||
self.id == other.id
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Insertable, Debug)]
|
||||
#[table_name="recipes"]
|
||||
pub struct NewRecipe<'a> {
|
||||
|
||||
Reference in New Issue
Block a user