makes models and schema modules privates, adds re-exports
This commit is contained in:
Binary file not shown.
@@ -2,10 +2,12 @@ extern crate cookbook;
|
||||
extern crate diesel;
|
||||
|
||||
use self::cookbook::*;
|
||||
use self::models::*;
|
||||
|
||||
use diesel::sqlite::SqliteConnection;
|
||||
use cookbook::models::fields::IngredientList;
|
||||
use cookbook::{
|
||||
ingredients::IngredientList,
|
||||
recipes::Recipe,
|
||||
};
|
||||
|
||||
struct IngredientListManager<'a>(&'a SqliteConnection, IngredientList);
|
||||
|
||||
@@ -28,6 +30,6 @@ fn main() {
|
||||
for rec in result {
|
||||
println!("*************\n{}\n({:?})", rec.title, rec.category);
|
||||
println!("-------------\n");
|
||||
println!("{}", rec.ingredients.as_string());
|
||||
println!("{}", IngredientListManager(&conn, rec.ingredients).display_lines());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,9 @@ extern crate diesel;
|
||||
|
||||
use std::io::{stdin};
|
||||
use diesel::SqliteConnection;
|
||||
use self::cookbook::*;
|
||||
use self::models::{NewRecipe, fields::RecipeCategory, fields::IngredientList};
|
||||
use cookbook::*;
|
||||
use cookbook::recipes::{NewRecipe, RecipeCategory};
|
||||
use cookbook::ingredients::{IngredientList};
|
||||
|
||||
struct CreateRecipe<'a> {
|
||||
connection: &'a SqliteConnection,
|
||||
@@ -33,7 +34,7 @@ impl<'a> CreateRecipe<'a> {
|
||||
|
||||
fn add_ingredient(&mut self, name: String) {
|
||||
use crate::ingredients::*;
|
||||
|
||||
let name = name.trim();
|
||||
// Check it exists or create
|
||||
match get_id_or_create(self.connection, &name) {
|
||||
Ok(id) => {
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
extern crate diesel;
|
||||
extern crate dotenv;
|
||||
|
||||
pub mod schema;
|
||||
pub mod models;
|
||||
mod schema;
|
||||
mod models;
|
||||
|
||||
mod importer;
|
||||
|
||||
@@ -20,7 +20,7 @@ pub fn establish_connection() -> SqliteConnection {
|
||||
}
|
||||
|
||||
pub mod recipes {
|
||||
use crate::models::{Recipe};
|
||||
pub use crate::models::{Recipe, NewRecipe, fields::RecipeCategory};
|
||||
use super::{SqliteConnection, schema};
|
||||
use super::diesel::prelude::*;
|
||||
|
||||
@@ -41,7 +41,11 @@ pub mod recipes {
|
||||
}
|
||||
|
||||
pub mod ingredients {
|
||||
use crate::models::{Ingredient, NewIngredient, fields::IngredientId};
|
||||
pub use crate::models::{
|
||||
Ingredient,
|
||||
NewIngredient,
|
||||
fields::{IngredientId, IngredientList},
|
||||
};
|
||||
use super::{SqliteConnection, schema};
|
||||
use super::diesel::prelude::*;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user