Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cascade #540

Closed
Ilqjx opened this issue Feb 17, 2022 · 4 comments
Closed

Cascade #540

Ilqjx opened this issue Feb 17, 2022 · 4 comments

Comments

@Ilqjx
Copy link

Ilqjx commented Feb 17, 2022

Table Person
image

Table Animal
image

The generated model is like this, I mean a person has many animals, but I don't see anything similar to the generation of animals: Vec<Animal>. If I want to get the animals under the person, how should I do it?

// person
pub struct Model {
    #[sea_orm(primary_key, auto_increment = false)]
    pub id: i32,
    pub name: String,
}

// animal
pub struct Model {
    #[sea_orm(primary_key, auto_increment = false)]
    pub id: i32,
    pub name: String,
    pub pid: i32,
}
@billy1624
Copy link
Member

Hey @Ilqjx, you can select related models via lazy loading or eager loading.
More on https://www.sea-ql.org/SeaORM/docs/basic-crud/select#find-related-models

@Ilqjx
Copy link
Author

Ilqjx commented Feb 17, 2022

Hello @billy1624, I know these two apis exist, what I want to know is can animals: Vec<Animal> be included in the generated struct. Like this:

pub struct Model {
    #[sea_orm(primary_key, auto_increment = false)]
    pub id: i32,
    pub name: String,
    pub animals: Vec<Animal>,
}

This will make it more convenient to obtain animals, such as person.animals.

@Ilqjx Ilqjx mentioned this issue Feb 17, 2022
@billy1624
Copy link
Member

This will make it more convenient to obtain animals, such as person.animals.

Similar feature is under development, see #415 for details

@Ilqjx
Copy link
Author

Ilqjx commented Feb 17, 2022

Ok, thanks for your reply.

@Ilqjx Ilqjx closed this as completed Feb 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants