pub struct AggregateCount<'a, M: 'static, PK: 'static> { /* private fields */ }Implementations§
Source§impl<'a, M: 'static, PK: 'static> AggregateCount<'a, M, PK>
impl<'a, M: 'static, PK: 'static> AggregateCount<'a, M, PK>
pub fn where_(self, filter: Filter) -> Self
pub fn where_expr(self, filter: FilterExpr) -> Self
pub fn where_any(self, filters: impl IntoIterator<Item = FilterExpr>) -> Self
pub fn where_optional<F>(self, filter: Option<F>) -> Selfwhere
F: Into<FilterExpr>,
Sourcepub fn preview_scoped_sql(&self, ctx: &CratestackContext) -> String
pub fn preview_scoped_sql(&self, ctx: &CratestackContext) -> String
The exact COUNT(*) SQL this would run, without executing it —
built by the same build_query that run/run_in_tx use, so
this can’t drift from what actually gets sent (unlike a
hand-rolled preview string-builder). No live DB connection is
required: QueryBuilder assembly is pure string/bind-slot
bookkeeping.
pub async fn run(self, ctx: &CratestackContext) -> Result<i64, CratestackError>
pub async fn run_in_tx<'tx>( self, tx: &mut Transaction<'tx, Postgres>, ctx: &CratestackContext, ) -> Result<i64, CratestackError>
Trait Implementations§
Source§impl<'a, M: Clone + 'static, PK: Clone + 'static> Clone for AggregateCount<'a, M, PK>
impl<'a, M: Clone + 'static, PK: Clone + 'static> Clone for AggregateCount<'a, M, PK>
Source§fn clone(&self) -> AggregateCount<'a, M, PK>
fn clone(&self) -> AggregateCount<'a, M, PK>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'a, M: 'static, PK: 'static> From<FindMany<'a, M, PK>> for AggregateCount<'a, M, PK>
Reuses the exact filters a find_many builder assembled for a
FindMany, discarding order_by/limit/offset/for_update —
meaningless for a scalar COUNT(*). Both FindMany::run and
AggregateCount::run push their WHERE clause through the same
[push_scoped_conditions] with the same descriptor and
[ReadPolicyKind::List], so transferring filters verbatim (rather
than re-deriving them from the caller’s query a second time) is what
guarantees the count can’t apply a different WHERE clause or
policy scope than the page it describes — see cratestack#570, whose
whole risk was exactly that kind of divergence.
impl<'a, M: 'static, PK: 'static> From<FindMany<'a, M, PK>> for AggregateCount<'a, M, PK>
Reuses the exact filters a find_many builder assembled for a
FindMany, discarding order_by/limit/offset/for_update —
meaningless for a scalar COUNT(*). Both FindMany::run and
AggregateCount::run push their WHERE clause through the same
[push_scoped_conditions] with the same descriptor and
[ReadPolicyKind::List], so transferring filters verbatim (rather
than re-deriving them from the caller’s query a second time) is what
guarantees the count can’t apply a different WHERE clause or
policy scope than the page it describes — see cratestack#570, whose
whole risk was exactly that kind of divergence.
Auto Trait Implementations§
impl<'a, M, PK> !RefUnwindSafe for AggregateCount<'a, M, PK>
impl<'a, M, PK> !UnwindSafe for AggregateCount<'a, M, PK>
impl<'a, M, PK> Freeze for AggregateCount<'a, M, PK>
impl<'a, M, PK> Send for AggregateCount<'a, M, PK>
impl<'a, M, PK> Sync for AggregateCount<'a, M, PK>
impl<'a, M, PK> Unpin for AggregateCount<'a, M, PK>
impl<'a, M, PK> UnsafeUnpin for AggregateCount<'a, M, PK>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more