pub struct SessionLoadQuery<'a, C: CanisterKind, E: EntityKind<Canister = C>> { /* private fields */ }Expand description
SessionLoadQuery
Fluent, session-bound load query wrapper that keeps intent pure
while routing execution through the DbSession boundary.
Implementations§
Source§impl<'a, C: CanisterKind, E: EntityKind<Canister = C>> SessionLoadQuery<'a, C, E>
impl<'a, C: CanisterKind, E: EntityKind<Canister = C>> SessionLoadQuery<'a, C, E>
Sourcepub fn many<I>(self, keys: I) -> Selfwhere
I: IntoIterator<Item = E::PrimaryKey>,
pub fn many<I>(self, keys: I) -> Selfwhere
I: IntoIterator<Item = E::PrimaryKey>,
Load multiple entities by primary key.
Semantics:
- Equivalent to
WHERE pk IN (…) - Uses key-based access (ByKey / ByKeys)
- Missing keys are ignored in MissingOk mode
- Strict mode treats missing rows as corruption
- Empty input yields an empty result set
Sourcepub fn filter(self, predicate: Predicate) -> Self
pub fn filter(self, predicate: Predicate) -> Self
Add a predicate, implicitly AND-ing with any existing predicate.
Sourcepub fn filter_expr(self, expr: FilterExpr) -> Result<Self, QueryError>
pub fn filter_expr(self, expr: FilterExpr) -> Result<Self, QueryError>
Apply a dynamic filter expression.
Sourcepub fn sort_expr(self, expr: SortExpr) -> Result<Self, QueryError>
pub fn sort_expr(self, expr: SortExpr) -> Result<Self, QueryError>
Apply a dynamic sort expression.
Sourcepub fn order_by_desc(self, field: impl AsRef<str>) -> Self
pub fn order_by_desc(self, field: impl AsRef<str>) -> Self
Append a descending sort key.
Sourcepub fn explain(&self) -> Result<ExplainPlan, QueryError>
pub fn explain(&self) -> Result<ExplainPlan, QueryError>
Explain this query without executing it.
Sourcepub fn plan(&self) -> Result<ExecutablePlan<E>, QueryError>
pub fn plan(&self) -> Result<ExecutablePlan<E>, QueryError>
Plan this query into an executor-ready plan.
Sourcepub fn execute(&self) -> Result<Response<E>, QueryError>
pub fn execute(&self) -> Result<Response<E>, QueryError>
Execute this query using the session’s policy settings.
Sourcepub fn exists(&self) -> Result<bool, QueryError>
pub fn exists(&self) -> Result<bool, QueryError>
Return whether any rows match this query.
Sourcepub fn is_empty(&self) -> Result<bool, QueryError>
pub fn is_empty(&self) -> Result<bool, QueryError>
Execute and return whether the response is empty.
Sourcepub fn count(&self) -> Result<u32, QueryError>
pub fn count(&self) -> Result<u32, QueryError>
Execute and return the number of matching rows.
Sourcepub fn require_one(&self) -> Result<(), QueryError>
pub fn require_one(&self) -> Result<(), QueryError>
Execute and require exactly one row.
Sourcepub fn require_some(&self) -> Result<(), QueryError>
pub fn require_some(&self) -> Result<(), QueryError>
Execute and require at least one row.
pub fn row(&self) -> Result<Row<E>, QueryError>
pub fn try_row(&self) -> Result<Option<Row<E>>, QueryError>
pub fn rows(&self) -> Result<Vec<Row<E>>, QueryError>
pub fn entity(&self) -> Result<E, QueryError>
pub fn try_entity(&self) -> Result<Option<E>, QueryError>
pub fn entities(&self) -> Result<Vec<E>, QueryError>
Sourcepub fn group_count_by<K>(
&self,
key: impl Fn(&E) -> K,
) -> Result<HashMap<K, u32>, QueryError>
pub fn group_count_by<K>( &self, key: impl Fn(&E) -> K, ) -> Result<HashMap<K, u32>, QueryError>
Execute and count entities grouped by the provided key selector.
Sourcepub fn one(&self) -> Result<E, QueryError>
pub fn one(&self) -> Result<E, QueryError>
Alias for entity.
Sourcepub fn one_opt(&self) -> Result<Option<E>, QueryError>
pub fn one_opt(&self) -> Result<Option<E>, QueryError>
Alias for try_entity.
Sourcepub fn all(&self) -> Result<Vec<E>, QueryError>
pub fn all(&self) -> Result<Vec<E>, QueryError>
Alias for entities.