You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
impl Into for InsertModel {
fn into(self) -> ActiveModel {
let mut uid = NotSet;
if let Some(id) = self.id {
uid = Set(Uuid::parse_str(&id).unwrap());
}
ActiveModel {
id: uid,
title: Set(self.title),
text: Set(self.text),
}
}
}
`
is there any better method to achieve? i have seen the DeriveIntoActiveModel, but there is some error occur.seems like can't transform
Option<Uuid> or Option<String> into uuid
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
this is my code below:
`
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub title: String,
pub text: String,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct InsertModel {
pub id: Option,
pub title: String,
pub text: String,
}
impl Into for InsertModel {
fn into(self) -> ActiveModel {
let mut uid = NotSet;
if let Some(id) = self.id {
uid = Set(Uuid::parse_str(&id).unwrap());
}
ActiveModel {
id: uid,
title: Set(self.title),
text: Set(self.text),
}
}
}
`
is there any better method to achieve? i have seen the DeriveIntoActiveModel, but there is some error occur.seems like can't transform
Option<Uuid> or Option<String> into uuid
Beta Was this translation helpful? Give feedback.
All reactions