Skip to main content

FluentLoadQuery

Struct FluentLoadQuery 

Source
pub struct FluentLoadQuery<'a, E>
where E: EntityKind,
{ /* private fields */ }
Expand description

FluentLoadQuery

Session-bound load query wrapper. Owns intent construction and execution routing only. All result inspection and projection is performed on Response<E>.

Implementations§

Source§

impl<'a, E> FluentLoadQuery<'a, E>
where E: EntityKind,

Source

pub const fn query(&self) -> &Query<E>

Source

pub fn by_id(self, id: Id<E>) -> Self

Set the access path to a single typed primary-key value.

Id<E> is treated as a plain query input value here. It does not grant access.

Source

pub fn by_ids<I>(self, ids: I) -> Self
where I: IntoIterator<Item = Id<E>>,

Set the access path to multiple typed primary-key values.

IDs are public and may come from untrusted input sources.

Source

pub fn filter(self, predicate: Predicate) -> Self

Source

pub fn filter_expr(self, expr: FilterExpr) -> Result<Self, QueryError>

Source

pub fn sort_expr(self, expr: SortExpr) -> Result<Self, QueryError>

Source

pub fn order_by(self, field: impl AsRef<str>) -> Self

Source

pub fn order_by_desc(self, field: impl AsRef<str>) -> Self

Source

pub fn limit(self, limit: u32) -> Self

Bound the number of returned rows.

Pagination is only valid with explicit ordering; combine limit and/or offset with order_by(...) or planning fails.

Source

pub fn offset(self, offset: u32) -> Self

Skip a number of rows in the ordered result stream.

Pagination is only valid with explicit ordering; combine offset and/or limit with order_by(...) or planning fails.

Source

pub fn cursor(self, token: impl Into<String>) -> Self

Attach an opaque cursor token for continuation pagination.

Cursor-mode invariants are checked before planning/execution:

  • explicit order_by(...) is required
  • explicit limit(...) is required
Source

pub fn explain(&self) -> Result<ExplainPlan, QueryError>

Source

pub fn plan(&self) -> Result<ExecutablePlan<E>, QueryError>

Source

pub fn execute(&self) -> Result<Response<E>, QueryError>
where E: EntityValue,

Execute this query using the session’s policy settings.

Source

pub fn page(self) -> Result<PagedLoadQuery<'a, E>, QueryError>

Enter typed cursor-pagination mode for this query.

Cursor pagination requires:

  • explicit order_by(...)
  • explicit limit(...)

Requests are deterministic under canonical ordering, but continuation is best-effort and forward-only over live state. No snapshot/version is pinned across requests, so concurrent writes may shift page boundaries.

Source

pub fn execute_paged(self) -> Result<(Response<E>, Option<Vec<u8>>), QueryError>
where E: EntityValue,

Execute this query as cursor pagination and return items + next cursor.

The returned cursor token is opaque and must be passed back via .cursor(...).

Source

pub fn is_empty(&self) -> Result<bool, QueryError>
where E: EntityValue,

Execute and return whether the result set is empty.

Source

pub fn exists(&self) -> Result<bool, QueryError>
where E: EntityValue,

Execute and return whether at least one matching row exists.

Source

pub fn count(&self) -> Result<u32, QueryError>
where E: EntityValue,

Execute and return the number of matching rows.

Source

pub fn min(&self) -> Result<Option<Id<E>>, QueryError>
where E: EntityValue,

Execute and return the smallest matching identifier, if any.

Source

pub fn min_by( &self, field: impl AsRef<str>, ) -> Result<Option<Id<E>>, QueryError>
where E: EntityValue,

Execute and return the id of the row with the smallest value for field.

Ties are deterministic: equal field values resolve by primary key ascending.

Source

pub fn max(&self) -> Result<Option<Id<E>>, QueryError>
where E: EntityValue,

Execute and return the largest matching identifier, if any.

Source

pub fn max_by( &self, field: impl AsRef<str>, ) -> Result<Option<Id<E>>, QueryError>
where E: EntityValue,

Execute and return the id of the row with the largest value for field.

Ties are deterministic: equal field values resolve by primary key ascending.

Source

pub fn nth_by( &self, field: impl AsRef<str>, nth: usize, ) -> Result<Option<Id<E>>, QueryError>
where E: EntityValue,

Execute and return the id at zero-based ordinal nth when rows are ordered by field ascending, with primary-key ascending tie-breaks.

Source

pub fn sum_by( &self, field: impl AsRef<str>, ) -> Result<Option<Decimal>, QueryError>
where E: EntityValue,

Execute and return the sum of field over matching rows.

Source

pub fn avg_by( &self, field: impl AsRef<str>, ) -> Result<Option<Decimal>, QueryError>
where E: EntityValue,

Execute and return the average of field over matching rows.

Source

pub fn median_by( &self, field: impl AsRef<str>, ) -> Result<Option<Id<E>>, QueryError>
where E: EntityValue,

Execute and return the median id by field using deterministic ordering (field asc, primary key asc).

Even-length windows select the lower median.

Source

pub fn count_distinct_by( &self, field: impl AsRef<str>, ) -> Result<u32, QueryError>
where E: EntityValue,

Execute and return the number of distinct values for field over the effective result window.

Source

pub fn min_max_by( &self, field: impl AsRef<str>, ) -> Result<Option<(Id<E>, Id<E>)>, QueryError>
where E: EntityValue,

Execute and return both (min_by(field), max_by(field)) in one terminal.

Tie handling is deterministic for both extrema: primary key ascending.

Source

pub fn first(&self) -> Result<Option<Id<E>>, QueryError>
where E: EntityValue,

Execute and return the first matching identifier in response order, if any.

Source

pub fn last(&self) -> Result<Option<Id<E>>, QueryError>
where E: EntityValue,

Execute and return the last matching identifier in response order, if any.

Source

pub fn require_one(&self) -> Result<(), QueryError>
where E: EntityValue,

Execute and require exactly one matching row.

Source

pub fn require_some(&self) -> Result<(), QueryError>
where E: EntityValue,

Execute and require at least one matching row.

Source§

impl<E> FluentLoadQuery<'_, E>

Source

pub fn only(self) -> Self

Auto Trait Implementations§

§

impl<'a, E> Freeze for FluentLoadQuery<'a, E>
where <E as EntityKey>::Key: Freeze,

§

impl<'a, E> !RefUnwindSafe for FluentLoadQuery<'a, E>

§

impl<'a, E> !Send for FluentLoadQuery<'a, E>

§

impl<'a, E> !Sync for FluentLoadQuery<'a, E>

§

impl<'a, E> Unpin for FluentLoadQuery<'a, E>
where E: Unpin, <E as EntityKey>::Key: Unpin,

§

impl<'a, E> UnsafeUnpin for FluentLoadQuery<'a, E>
where <E as EntityKey>::Key: UnsafeUnpin,

§

impl<'a, E> !UnwindSafe for FluentLoadQuery<'a, E>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V