* de(serialize) custom JSON types * Rename DeriveTryGetableFromJson -> FromJsonQueryResult Co-authored-by: Chris Tsang <chris.2y3@outlook.com>
26 lines
640 B
Rust
26 lines
640 B
Rust
use sea_orm::entity::prelude::*;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
|
|
#[sea_orm(table_name = "json_struct")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key)]
|
|
pub id: i32,
|
|
pub json: Json,
|
|
pub json_value: KeyValue,
|
|
pub json_value_opt: Option<KeyValue>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, FromJsonQueryResult)]
|
|
pub struct KeyValue {
|
|
pub id: i32,
|
|
pub name: String,
|
|
pub price: f32,
|
|
pub notes: Option<String>,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|