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

added get_subquery() and add_imported_fields, fixed soft-delete and join demos #31

Merged
merged 5 commits into from
Nov 15, 2024

Conversation

romaninsh
Copy link
Owner

@romaninsh romaninsh commented Nov 15, 2024

Thanks to get_subquery method, creating expressions for related tables is now much easier:

// Link Users with Orders and aggregate sum(total) into "orders_total"
users = users
    .with_many("orders", "user_id", || Order::table())
    .with_expression("orders_total", |t| {
        let o = t.get_subquery::<Order>("orders").unwrap()
        o.sum(o.total()).render_chunk()
    });

For with_one relation, there is also a new field for importing fields as-is.

users = users
    .with_one("role", "role_id", || Role::table())
    .with_imported_fields("role", &["name", "permission"]);

Oh and has_one -> with_one, and has_many -> with_many - for consistency!

You can also display table now:

println!("Table: {}", &table);

@romaninsh romaninsh changed the title added get_subquery() and add_imported_fields added get_subquery() and add_imported_fields, fixed soft-delete and join demos Nov 15, 2024
@romaninsh romaninsh merged commit 9ff6207 into main Nov 15, 2024
2 checks passed
@romaninsh romaninsh deleted the rm-branch-1 branch November 15, 2024 22:48
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

Successfully merging this pull request may close these issues.

1 participant