pub struct BatchUpdateResult<E> {
pub updated: Vec<E>,
pub skipped: usize,
}Expand description
批量更新结果
由 Repository::batch_update 返回,
区分成功更新的实体与因主键不存在而被跳过的实体数量。
§字段
updated:成功更新的实体列表(按主键匹配命中并完成 UPDATE)skipped:主键不存在而被跳过的实体数量
§设计动机
SeaORM 的 update_many 不区分“存在“与“不存在“,只返回受影响行数。
本结构明确区分两者,便于调用方感知部分失败(如批量同步外部数据时
部分记录已被删除)并采取补偿措施(记录日志、重试插入等)。
Fields§
§updated: Vec<E>成功更新的实体列表
skipped: usize主键不存在而被跳过的实体数量
Implementations§
Source§impl<E> BatchUpdateResult<E>
impl<E> BatchUpdateResult<E>
Sourcepub fn updated_count(&self) -> usize
pub fn updated_count(&self) -> usize
成功更新数量
Sourcepub fn has_skipped(&self) -> bool
pub fn has_skipped(&self) -> bool
是否有跳过的实体
Sourcepub fn all_updated(&self) -> bool
pub fn all_updated(&self) -> bool
是否全部成功(无跳过)
Sourcepub fn map<U, F: Fn(E) -> U>(self, f: F) -> BatchUpdateResult<U>
pub fn map<U, F: Fn(E) -> U>(self, f: F) -> BatchUpdateResult<U>
映射已更新实体为其他类型(保留 skipped 计数)
Trait Implementations§
Source§impl<E: Clone> Clone for BatchUpdateResult<E>
impl<E: Clone> Clone for BatchUpdateResult<E>
Source§fn clone(&self) -> BatchUpdateResult<E>
fn clone(&self) -> BatchUpdateResult<E>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<E: Debug> Debug for BatchUpdateResult<E>
impl<E: Debug> Debug for BatchUpdateResult<E>
Auto Trait Implementations§
impl<E> Freeze for BatchUpdateResult<E>
impl<E> RefUnwindSafe for BatchUpdateResult<E>where
E: RefUnwindSafe,
impl<E> Send for BatchUpdateResult<E>where
E: Send,
impl<E> Sync for BatchUpdateResult<E>where
E: Sync,
impl<E> Unpin for BatchUpdateResult<E>where
E: Unpin,
impl<E> UnsafeUnpin for BatchUpdateResult<E>
impl<E> UnwindSafe for BatchUpdateResult<E>where
E: UnwindSafe,
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
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>
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