Creates a simple planning
This commit is contained in:
Binary file not shown.
@@ -10,7 +10,6 @@ fn main() {
|
||||
|
||||
let conn = establish_connection();
|
||||
let result = recipes
|
||||
.limit(5)
|
||||
.load::<Recipe>(&conn)
|
||||
.expect("Error loading recipes");
|
||||
|
||||
|
||||
@@ -21,6 +21,18 @@ pub fn establish_connection() -> SqliteConnection {
|
||||
.expect(&format!("Error connecting to {}", db_url))
|
||||
}
|
||||
|
||||
pub mod recipes {
|
||||
use crate::models::{Recipe, NewRecipe};
|
||||
use super::{SqliteConnection, schema};
|
||||
use super::diesel::prelude::*;
|
||||
|
||||
pub fn load_all(conn: &SqliteConnection) -> Vec<Recipe> {
|
||||
use self::schema::recipes::dsl::*;
|
||||
recipes.load::<Recipe>(conn)
|
||||
.expect("Error loading recipe's list")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub mod ingredients {
|
||||
use crate::models::{Ingredient, NewIngredient};
|
||||
|
||||
@@ -2,7 +2,7 @@ use super::schema::recipes;
|
||||
use super::schema::ingredients;
|
||||
use super::diesel::prelude::*;
|
||||
|
||||
#[derive(Queryable)]
|
||||
#[derive(Debug, Clone, Queryable)]
|
||||
pub struct Recipe {
|
||||
pub id: i32,
|
||||
pub title: String,
|
||||
|
||||
Reference in New Issue
Block a user