#[non_exhaustive]pub struct KeysetCondition {
pub sort_fields: Vec<SortField>,
pub cursor_values: Vec<Value>,
pub forward: bool,
}Expand description
Keyset pagination condition.
Generates efficient (col1, col2) > ($1, $2) style WHERE clauses
for keyset/seek pagination.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.sort_fields: Vec<SortField>The sort fields and their directions.
cursor_values: Vec<Value>The cursor values for each field.
forward: boolDirection: true for “after”, false for “before”.
Implementations§
Source§impl KeysetCondition
impl KeysetCondition
Sourcepub fn after(sorts: &[SortField], cursor: &Cursor) -> Option<Self>
pub fn after(sorts: &[SortField], cursor: &Cursor) -> Option<Self>
Create a new keyset condition for paginating after a cursor.
Sourcepub fn before(sorts: &[SortField], cursor: &Cursor) -> Option<Self>
pub fn before(sorts: &[SortField], cursor: &Cursor) -> Option<Self>
Create a new keyset condition for paginating before a cursor.
Sourcepub fn to_filter_expr(&self) -> FilterExpr
pub fn to_filter_expr(&self) -> FilterExpr
Convert to a filter expression for the query builder.
For a single field, generates: field > $1 (or < for DESC)
For multiple fields, generates proper compound OR conditions:
(a, b) > (1, 2) becomes: (a > 1) OR (a = 1 AND b > 2)
For 3+ fields: (a > 1) OR (a = 1 AND b > 2) OR (a = 1 AND b = 2 AND c > 3)
This follows the keyset pagination standard used by PostgreSQL, GraphQL Relay, and major ORMs. See: https://use-the-index-luke.com/no-offset
Trait Implementations§
Source§impl Clone for KeysetCondition
impl Clone for KeysetCondition
Source§fn clone(&self) -> KeysetCondition
fn clone(&self) -> KeysetCondition
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more