Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- impl<T> Paginated<T> {
- pub fn load_page<U: Serialize>(self, conn: &PgConnection) -> QueryResult<Page<U>>
- where
- Self: LoadQuery<PgConnection, U>,
- T: SelectDsl<_>
- {
- use diesel::dsl::count_star;
- let total = self.query.select(count_star()).first(conn)?;
- let items = self.load::<U>(conn)?;
- Ok(Page{items, total})
- }
- }
Add Comment
Please, Sign In to add comment