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

Getters for foreign keys and primary keys #1

Open
tvallotton opened this issue Sep 6, 2021 · 0 comments
Open

Getters for foreign keys and primary keys #1

tvallotton opened this issue Sep 6, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@tvallotton
Copy link
Owner

tvallotton commented Sep 6, 2021

Add support for getters for forein keys, with the following API:

#[derive(Model)]
struct Post {
    #[primary_key]
    id: i32, 
    #[foreign_key(User.id, on_delete="cascade")]
    author: i32
}

let post: Post =  Post::from_key(&mut conn, &id).await?;

let user: User = post.author(&mut conn).await?;
@tvallotton tvallotton changed the title Getters for foreign keys Getters for foreign keys and primary keys Sep 7, 2021
@tvallotton tvallotton added the enhancement New feature or request label Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant