Can you have a second Model as a type in another one. #2015
Answered
by
tyt2y3
DenuxPlays
asked this question in
Q&A
-
Hey, #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "user")]
pub struct User {
#[sea_orm(primary_key)]
pub id: i32,
pub username: String,
pub email: Option<String>,
pub password: String,
}
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "api_key")]
pub struct ApiKey {
#[sea_orm(primary_key)]
pub id: i32,
pub key: String,
pub created_at: DateTime,
pub user: User,
} Just ignore that the struct aren't named |
Beta Was this translation helpful? Give feedback.
Answered by
tyt2y3
Dec 18, 2023
Replies: 2 comments
-
Or how can I make this work? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi nested structs are possible if the inner struct is JSON serializable. But not nested entities. Reference: https://www.sea-ql.org/SeaORM/docs/generate-entity/entity-structure/#column-type , |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
DenuxPlays
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi nested structs are possible if the inner struct is JSON serializable. But not nested entities.
Reference: https://www.sea-ql.org/SeaORM/docs/generate-entity/entity-structure/#column-type ,
FromJsonQueryResult