Adds write script for recipes, adds ingredients migrations

This commit is contained in:
2019-01-28 15:23:39 +01:00
parent fb4d24ef44
commit 202d7c5976
8 changed files with 134 additions and 1 deletions

View File

@@ -1,3 +1,6 @@
use super::schema::recipes;
use super::schema::ingredients;
#[derive(Queryable)]
pub struct Recipe {
pub id: i32,
@@ -6,3 +9,24 @@ pub struct Recipe {
pub ingredients: String,
pub preparation: String,
}
#[derive(Insertable)]
#[table_name="recipes"]
pub struct NewRecipe<'a> {
pub title: &'a str,
pub category: i32,
pub ingredients: String,
pub preparation: &'a str,
}
#[derive(Queryable)]
pub struct Ingredient {
pub id: i32,
pub alias: String,
}
#[derive(Insertable)]
#[table_name="ingredients"]
pub struct NewIngredient<'a> {
pub alias: &'a str,
}