pub struct ModelDelegate<'a, M: 'static, PK: 'static> { /* private fields */ }Implementations§
Source§impl<'a, M: 'static, PK: 'static> ModelDelegate<'a, M, PK>
impl<'a, M: 'static, PK: 'static> ModelDelegate<'a, M, PK>
pub fn new( runtime: &'a SqlxRuntime, descriptor: &'static ModelDescriptor<M, PK>, ) -> Self
pub fn descriptor(&self) -> &'static ModelDescriptor<M, PK>
pub fn bind(self, ctx: CoolContext) -> ScopedModelDelegate<'a, M, PK>
pub fn find_many(&self) -> FindMany<'a, M, PK>
pub fn find_unique(&self, id: PK) -> FindUnique<'a, M, PK>
pub fn create<I>(&self, input: I) -> CreateRecord<'a, M, PK, I>
Sourcepub fn upsert<I>(&self, input: I) -> UpsertRecord<'a, M, PK, I>
pub fn upsert<I>(&self, input: I) -> UpsertRecord<'a, M, PK, I>
Insert-or-update on primary-key conflict. Available only on
models whose @id field is client-supplied (no @default(...));
attempting to call this on a model with a server-generated PK
is a compile error.
pub fn update(&self, id: PK) -> UpdateRecord<'a, M, PK>
Sourcepub fn update_many(&self) -> UpdateMany<'a, M, PK>
pub fn update_many(&self) -> UpdateMany<'a, M, PK>
Bulk UPDATE by predicate. Refuses to run without at least one filter — table-wide bulk updates are a footgun that should be written in raw SQL.
pub fn delete(&self, id: PK) -> DeleteRecord<'a, M, PK>
Sourcepub fn aggregate(&self) -> Aggregate<'a, M, PK>
pub fn aggregate(&self) -> Aggregate<'a, M, PK>
Side-effect-free aggregate read. Returns a builder that
branches into .count() / .sum(col) / .avg(col) /
.min(col) / .max(col). Aggregates apply the read policy
AND soft-delete column so the result always describes rows the
caller could retrieve via find_many.
Sourcepub fn delete_many(&self) -> DeleteMany<'a, M, PK>
pub fn delete_many(&self) -> DeleteMany<'a, M, PK>
Bulk DELETE by predicate. Mirrors update_many: applies the
delete policy and soft-delete column (if any), fans audit +
outbox out per-row via RETURNING, refuses to run without at
least one filter.
Source§impl<'a, M: 'static, PK: 'static> ModelDelegate<'a, M, PK>
impl<'a, M: 'static, PK: 'static> ModelDelegate<'a, M, PK>
Source§impl<'a, M: 'static, PK: 'static> ModelDelegate<'a, M, PK>
impl<'a, M: 'static, PK: 'static> ModelDelegate<'a, M, PK>
Sourcepub fn batch_get(&self, ids: Vec<PK>) -> BatchGet<'a, M, PK>
pub fn batch_get(&self, ids: Vec<PK>) -> BatchGet<'a, M, PK>
Fetch many rows by primary key in a single round-trip; missing
rows surface as per-item NotFound in the envelope rather
than aborting.
Sourcepub fn batch_create<I>(&self, inputs: Vec<I>) -> BatchCreate<'a, M, PK, I>
pub fn batch_create<I>(&self, inputs: Vec<I>) -> BatchCreate<'a, M, PK, I>
Insert many rows in one outer transaction; each input runs under a nested SAVEPOINT, so a per-item failure (validation, policy, unique conflict) doesn’t take down the rest of the batch.
Sourcepub fn batch_update<I>(
&self,
items: Vec<BatchUpdateItem<PK, I>>,
) -> BatchUpdate<'a, M, PK, I>
pub fn batch_update<I>( &self, items: Vec<BatchUpdateItem<PK, I>>, ) -> BatchUpdate<'a, M, PK, I>
Update many rows in one outer transaction with per-item
patches and optional if_match versions. Per-item failures
roll back at the savepoint; successful items commit together.
Sourcepub fn batch_delete(&self, ids: Vec<PK>) -> BatchDelete<'a, M, PK>
pub fn batch_delete(&self, ids: Vec<PK>) -> BatchDelete<'a, M, PK>
Delete many rows by primary key in a single statement; rows
that don’t exist (or that policy hid) surface as per-item
NotFound.
Sourcepub fn batch_upsert<I>(&self, inputs: Vec<I>) -> BatchUpsert<'a, M, PK, I>
pub fn batch_upsert<I>(&self, inputs: Vec<I>) -> BatchUpsert<'a, M, PK, I>
Insert-or-update many rows in one outer transaction with
per-item savepoints. Eligible only for models whose @id is
client-supplied — same compile-time gate as the single-row
.upsert(...).
Trait Implementations§
Source§impl<'a, M: Clone + 'static, PK: Clone + 'static> Clone for ModelDelegate<'a, M, PK>
impl<'a, M: Clone + 'static, PK: Clone + 'static> Clone for ModelDelegate<'a, M, PK>
Source§fn clone(&self) -> ModelDelegate<'a, M, PK>
fn clone(&self) -> ModelDelegate<'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 moreimpl<'a, M: Copy + 'static, PK: Copy + 'static> Copy for ModelDelegate<'a, M, PK>
Auto Trait Implementations§
impl<'a, M, PK> Freeze for ModelDelegate<'a, M, PK>
impl<'a, M, PK> !RefUnwindSafe for ModelDelegate<'a, M, PK>
impl<'a, M, PK> Send for ModelDelegate<'a, M, PK>
impl<'a, M, PK> Sync for ModelDelegate<'a, M, PK>
impl<'a, M, PK> Unpin for ModelDelegate<'a, M, PK>
impl<'a, M, PK> UnsafeUnpin for ModelDelegate<'a, M, PK>
impl<'a, M, PK> !UnwindSafe for ModelDelegate<'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
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