diff --git a/common/src/models/article.rs b/common/src/models/article.rs index 3f4ffc0..d3cfb8f 100644 --- a/common/src/models/article.rs +++ b/common/src/models/article.rs @@ -21,6 +21,7 @@ pub struct Article { pub bio_origin: Option, pub allergens_text: Option, pub bio_info: Option, + pub topm_id: Option, } fn from_postgres_row_small(row: PgRow) -> Article { @@ -37,6 +38,7 @@ fn from_postgres_row_small(row: PgRow) -> Article { bio_origin: row.get(8), allergens_text: row.get(9), bio_info: row.get(10), + topm_id: row.get(11), } } @@ -67,6 +69,7 @@ async fn from_postgres_row(row: PgRow, pool: PgPool) -> Article { bio_origin: row.get(8), allergens_text: row.get(9), bio_info: row.get(10), + topm_id: row.get(11), } } @@ -137,9 +140,10 @@ pub async fn insert_article(article: &Article, pool: PgPool) -> Option
args.add(&article.bio_origin); args.add(&article.allergens_text); args.add(&article.bio_info); + args.add(&article.topm_id); let statement = format!( - "INSERT INTO {} (name, bio, origin, description, ingredients, default_unit_id, mhd, bio_origin, allergens_text, bio_info) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) RETURNING *", + "INSERT INTO {} (name, bio, origin, description, ingredients, default_unit_id, mhd, bio_origin, allergens_text, bio_info, topm_id) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) RETURNING *", "article", ); @@ -176,9 +180,10 @@ pub async fn update_article(article_id: i64, article: &Article, pool: PgPool) -> args.add(&article.bio_origin); args.add(&article.allergens_text); args.add(&article.bio_info); + args.add(&article.topm_id); let statement = format!( - "UPDATE {} SET name = $2, bio = $3, origin = $4, description = $5, ingredients = $6, default_unit_id = $7, mhd = $8, bio_origin = $9, allergens_text = $10, bio_info = $11 WHERE id = $1 RETURNING *", + "UPDATE {} SET name = $2, bio = $3, origin = $4, description = $5, ingredients = $6, default_unit_id = $7, mhd = $8, bio_origin = $9, allergens_text = $10, bio_info = $11, topm_id = $12 WHERE id = $1 RETURNING *", "article", ); diff --git a/common/src/models/variant.rs b/common/src/models/variant.rs index cfa274d..45821e5 100644 --- a/common/src/models/variant.rs +++ b/common/src/models/variant.rs @@ -16,6 +16,7 @@ pub struct Variant { pub unit: Unit, pub label: Option