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> {
|
||||
|
||||
Reference in New Issue
Block a user