[examples] create input model with DeriveIntoActiveModel
(#975)
This commit is contained in:
parent
87f7891f17
commit
3727f7b8b5
@ -70,20 +70,17 @@ mod form {
|
|||||||
use super::fruit::*;
|
use super::fruit::*;
|
||||||
use sea_orm::entity::prelude::*;
|
use sea_orm::entity::prelude::*;
|
||||||
|
|
||||||
#[derive(
|
#[derive(Clone, Debug, PartialEq, Eq, DeriveIntoActiveModel)]
|
||||||
Clone, Debug, PartialEq, Eq, DeriveModel, DeriveActiveModel, DeriveActiveModelBehavior,
|
pub struct InputModel {
|
||||||
)]
|
|
||||||
pub struct Model {
|
|
||||||
pub id: i32,
|
|
||||||
pub name: String,
|
pub name: String,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn save_custom_active_model(db: &DbConn) -> Result<(), DbErr> {
|
async fn save_custom_active_model(db: &DbConn) -> Result<(), DbErr> {
|
||||||
let pineapple = form::ActiveModel {
|
let pineapple = form::InputModel {
|
||||||
id: NotSet,
|
name: "Pineapple".to_owned(),
|
||||||
name: Set("Pineapple".to_owned()),
|
}
|
||||||
};
|
.into_active_model();
|
||||||
|
|
||||||
let pineapple = pineapple.save(db).await?;
|
let pineapple = pineapple.save(db).await?;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user