-
I want to get both count and rows, can I clone a query? Is there any better solution? let conn = get_conn().await;
let mut q = Entity::find();
let q = q.filter(...);
let count = q.clone().count().await;
let rows = q.offset(...).limit(...).all().await; |
Beta Was this translation helpful? Give feedback.
Answered by
billy1624
Dec 9, 2021
Replies: 1 comment
-
Hey @lz1998, you could use paginator to do both without cloning the query.
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
tyt2y3
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @lz1998, you could use paginator to do both without cloning the query.
.paginate()
and offset it with.fetch_page()
.num_items()
https://docs.rs/sea-orm/0.4.1/sea_orm/struct.Paginator.html