pub struct Update<M> { /* private fields */ }Expand description
A bulk UPDATE over model M, created with Model::update_all or
Select::update.
Managed columns are maintained automatically unless you set them
yourself: updated_at = now() for models with timestamps and
version = version + 1 for models with optimistic locking. Soft-deleted
rows are skipped unless the query used with_trashed/only_trashed.
Implementations§
Source§impl<M> Update<M>where
M: Model,
impl<M> Update<M>where
M: Model,
Sourcepub fn all_tenants(self) -> Update<M>
pub fn all_tenants(self) -> Update<M>
Update every tenant’s rows, ignoring the current tenant scope.
Sourcepub fn filter(self, expr: Expr<M>) -> Update<M>
pub fn filter(self, expr: Expr<M>) -> Update<M>
Add a WHERE condition. Multiple calls are combined with AND.
Sourcepub fn with_trashed(self) -> Update<M>
pub fn with_trashed(self) -> Update<M>
Also update soft-deleted rows.
Sourcepub fn set_raw<V>(
self,
column: Column<M>,
sql: impl Into<String>,
params: impl IntoIterator<Item = V>,
) -> Update<M>
pub fn set_raw<V>( self, column: Column<M>, sql: impl Into<String>, params: impl IntoIterator<Item = V>, ) -> Update<M>
SET column = <raw sql>, binding each ? to the next parameter.
ⓘ
Post::update_all().set_raw(Post::PUBLISHED_AT, "now()", [] as [i32; 0])Sourcepub fn increment(self, column: Column<M>, by: impl Into<Value>) -> Update<M>
pub fn increment(self, column: Column<M>, by: impl Into<Value>) -> Update<M>
SET column = column + by
Sourcepub fn decrement(self, column: Column<M>, by: impl Into<Value>) -> Update<M>
pub fn decrement(self, column: Column<M>, by: impl Into<Value>) -> Update<M>
SET column = column - by
Trait Implementations§
Auto Trait Implementations§
impl<M> !RefUnwindSafe for Update<M>
impl<M> !UnwindSafe for Update<M>
impl<M> Freeze for Update<M>
impl<M> Send for Update<M>
impl<M> Sync for Update<M>
impl<M> Unpin for Update<M>
impl<M> UnsafeUnpin for Update<M>
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
Mutably borrows from an owned value. Read more
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,
impl<M> InScope<(M, ()), Here> for M
impl<M, Rest, N> InScope<(M, (Rest, N)), Last> for N
impl<X, M, Rest, N, I> InScope<(M, (Rest, N)), There<I>> for X
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> ⓘ
Converts
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> ⓘ
Converts
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