summaryrefslogtreecommitdiffstats
path: root/src/models/model.rs
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2022-09-21 21:51:38 +0000
committerSanto Cariotti <santo@dcariotti.me>2022-09-21 21:51:38 +0000
commita30bcf0f0f32d6b1c822c631cf22fa9b13a5616a (patch)
tree487c2f515e76fc93e3a1846f88bb1024e01c2559 /src/models/model.rs
parenta3275b45ef2db23b10d8f430ec17886d89768389 (diff)
Deserialize float model values as number from string
Diffstat (limited to 'src/models/model.rs')
-rw-r--r--src/models/model.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/models/model.rs b/src/models/model.rs
index 03f872e..469356f 100644
--- a/src/models/model.rs
+++ b/src/models/model.rs
@@ -1,4 +1,4 @@
-use crate::{config::CONFIG, db::get_client, errors::AppError};
+use crate::{config::CONFIG, db::get_client, errors::AppError, json::number_from_string};
use serde_json::json;
use sqlx::types::JsonValue;
use sqlx::Row;
@@ -29,8 +29,11 @@ pub struct Model {
pub struct ModelCreate {
pub name: String,
pub description: Option<String>,
+ #[serde(deserialize_with = "number_from_string")]
pub duration: f64,
+ #[serde(deserialize_with = "number_from_string")]
pub height: f64,
+ #[serde(deserialize_with = "number_from_string")]
pub weight: f64,
pub printer: Option<String>,
pub material: Option<String>,