pub struct Page { /* private fields */ }Expand description
The struct used to perform pagination
Implementations
sourceimpl Page
impl Page
sourcepub fn new(smaller: bool, size: u32, columns: Vec<String>) -> Self
pub fn new(smaller: bool, size: u32, columns: Vec<String>) -> Self
Create a new Page.
smaller: Controls the direction of the pagination.
true: Select the rows towards the direction in which the cursor becomes smaller. The returned rows will be sorteddesc.false: Select the rows towards the direction in which the cursor becomes bigger. The returned rows will be sortedasc.
For example, if the sorting columns are (time_of_insertion, table_pkey),
and you want to scroll to the past, you should set smaller = true.
size: Size of the page.
columns:
Sort rows using these columns (up to 5).
Note that the joint of these columns should uniquely identifies a row.
sourcepub fn push_where1<'args, T1>(
&self,
builder: &mut QueryBuilder<'args, Postgres>,
cursors: Option<T1>
) where
T1: 'args + Encode<'args, Postgres> + Type<Postgres> + Send,
pub fn push_where1<'args, T1>(
&self,
builder: &mut QueryBuilder<'args, Postgres>,
cursors: Option<T1>
) where
T1: 'args + Encode<'args, Postgres> + Type<Postgres> + Send,
Push the pagination condition to the builder: QueryBuilder.
Roughly, push_whereN pushes and binds (col_1, col_2, ..., col_N) op ($_, $_, ..., $_)
to the builder, where op is chosen according to the pagination direction,
and N is the number of cursor columns.
Note, internally this calls builder::push/push_bind,
so it is as secure as the QueryBuilder.
pub fn push_where2<'args, T1, T2>(
&self,
builder: &mut QueryBuilder<'args, Postgres>,
cursors: Option<(T1, T2)>
) where
T1: 'args + Encode<'args, Postgres> + Type<Postgres> + Send,
T2: 'args + Encode<'args, Postgres> + Type<Postgres> + Send,
pub fn push_where3<'args, T1, T2, T3>(
&self,
builder: &mut QueryBuilder<'args, Postgres>,
cursors: Option<(T1, T2, T3)>
) where
T1: 'args + Encode<'args, Postgres> + Type<Postgres> + Send,
T2: 'args + Encode<'args, Postgres> + Type<Postgres> + Send,
T3: 'args + Encode<'args, Postgres> + Type<Postgres> + Send,
pub fn push_where4<'args, T1, T2, T3, T4>(
&self,
builder: &mut QueryBuilder<'args, Postgres>,
cursors: Option<(T1, T2, T3, T4)>
) where
T1: 'args + Encode<'args, Postgres> + Type<Postgres> + Send,
T2: 'args + Encode<'args, Postgres> + Type<Postgres> + Send,
T3: 'args + Encode<'args, Postgres> + Type<Postgres> + Send,
T4: 'args + Encode<'args, Postgres> + Type<Postgres> + Send,
pub fn push_where5<'args, T1, T2, T3, T4, T5>(
&self,
builder: &mut QueryBuilder<'args, Postgres>,
cursors: Option<(T1, T2, T3, T4, T5)>
) where
T1: 'args + Encode<'args, Postgres> + Type<Postgres> + Send,
T2: 'args + Encode<'args, Postgres> + Type<Postgres> + Send,
T3: 'args + Encode<'args, Postgres> + Type<Postgres> + Send,
T4: 'args + Encode<'args, Postgres> + Type<Postgres> + Send,
T5: 'args + Encode<'args, Postgres> + Type<Postgres> + Send,
sourcepub fn push_order_by(&self, builder: &mut QueryBuilder<'_, Postgres>)
pub fn push_order_by(&self, builder: &mut QueryBuilder<'_, Postgres>)
Push the order by clause order by (col_1, ...) asc/desc.
sourcepub fn push_limit(&self, builder: &mut QueryBuilder<'_, Postgres>)
pub fn push_limit(&self, builder: &mut QueryBuilder<'_, Postgres>)
Push the limit clause limit k.
Auto Trait Implementations
impl RefUnwindSafe for Page
impl Send for Page
impl Sync for Page
impl Unpin for Page
impl UnwindSafe for Page
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more