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
use sea_orm::DeriveModel;#[derive(DeriveModel)]pubstructModel{pubid:i32,pubname:String,}
impl sea_orm::ModelTraitforModel{typeEntity = Entity;fnget(&self,c: <Self::EntityasEntityTrait>::Column) -> sea_orm::Value{match c {
<Self::EntityasEntityTrait>::Column::Id => self.id.clone().into(),
<Self::EntityasEntityTrait>::Column::Name => self.name.clone().into(),
_ => ::std::rt::begin_panic("This Model does not have this field"),}}fnset(&mutself,c: <Self::EntityasEntityTrait>::Column,v: sea_orm::Value){match c {
<Self::EntityasEntityTrait>::Column::Id => self.id = v.unwrap(),
<Self::EntityasEntityTrait>::Column::Name => self.name = v.unwrap(),
_ => ::std::rt::begin_panic("This Model does not have this field"),}}}impl sea_orm::FromQueryResultforModel{fnfrom_query_result(row:&sea_orm::QueryResult,pre:&str) -> Result<Self, sea_orm::TypeErr>{Ok(Self{id: row.try_get(
pre,
<<SelfasModelTrait>::EntityasEntityTrait>::Column::Id.as_str().into(),)?,name: row.try_get(
pre,
<<SelfasModelTrait>::EntityasEntityTrait>::Column::Name.as_str().into(),)?,})}}
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
-
@acidic9
https://github.com/SeaQL/sea-orm/blob/master/sea-orm-macros/src/derives/model.rs
You can actually view the macro expansion by
cargo expand
Beta Was this translation helpful? Give feedback.
All reactions