Guest User

Untitled

a guest
Sep 26th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. impl<T> Paginated<T> {
  2. pub fn load_page<U: Serialize>(self, conn: &PgConnection) -> QueryResult<Page<U>>
  3. where
  4. Self: LoadQuery<PgConnection, U>,
  5. T: SelectDsl<_>
  6. {
  7. use diesel::dsl::count_star;
  8. let total = self.query.select(count_star()).first(conn)?;
  9. let items = self.load::<U>(conn)?;
  10. Ok(Page{items, total})
  11. }
  12. }
Add Comment
Please, Sign In to add comment