use crate::models::*; use crate::schema::products; #[derive(Debug, Insertable, AsChangeset)] #[table_name = "products"] pub struct ProductForm { pub id: i32, pub name: String, pub description: String, pub quantity: i32, pub cents: i32, pub featured: i32, pub photo_set: i32, pub category: String, } impl From for ProductForm { fn from(p: Product) -> Self { Self { id: p.id.unwrap_or(-1), name: p.name, description: p.description, quantity: p.quantity, cents: p.cents, featured: p.featured as i32, photo_set: p.photo_set.id.unwrap_or(-1), category: p.category, } } }