SeaQL / sea-orm

🐚 An async & dynamic ORM for Rust
https://www.sea-ql.org/SeaORM/
Apache License 2.0
7.3k stars 513 forks source link

How to use `into_model` combine with `cursor_by`? #1111

Closed billy1624 closed 2 years ago

billy1624 commented 2 years ago

Discussed in https://github.com/SeaQL/sea-orm/discussions/1101

Originally posted by **jukanntenn** October 8, 2022 This is the example from official docs [Handling Custom Selects](https://www.sea-ql.org/SeaORM/docs/advanced-query/custom-select/#handling-custom-selects) ```rust use sea_orm::{FromQueryResult, JoinType, RelationTrait}; use sea_query::Expr; #[derive(FromQueryResult)] struct CakeAndFillingCount { id: i32, name: String, count: i32, } let cake_counts: Vec = cake::Entity::find() .column_as(filling::Column::Id.count(), "count") .join_rev( // construct `RelationDef` on the fly JoinType::InnerJoin, cake_filling::Entity::belongs_to(cake::Entity) .from(cake_filling::Column::CakeId) .to(cake::Column::Id) .into() ) // reuse a `Relation` from existing Entity .join(JoinType::InnerJoin, cake_filling::Relation::Filling.def()) .group_by(cake::Column::Id) .into_model::() .all(db) .await?; ``` Then I also want to apply cursor pagination to the query, but `into_model` returns a `Selector` struct and `cursor_by` returns a `Cursor` struct. It seems they can not be used together or do I miss something?
billy1624 commented 2 years ago

CC @jukanntenn