Skip to main content

BatchUpdateResult

Struct BatchUpdateResult 

Source
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>

Source

pub fn new(updated: Vec<E>, skipped: usize) -> Self

创建批量更新结果

Source

pub fn updated_count(&self) -> usize

成功更新数量

Source

pub fn has_skipped(&self) -> bool

是否有跳过的实体

Source

pub fn all_updated(&self) -> bool

是否全部成功(无跳过)

Source

pub fn total(&self) -> usize

总计处理数量(已更新 + 跳过)

Source

pub fn map<U, F: Fn(E) -> U>(self, f: F) -> BatchUpdateResult<U>

映射已更新实体为其他类型(保留 skipped 计数)

Trait Implementations§

Source§

impl<E: Clone> Clone for BatchUpdateResult<E>

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl<E: Debug> Debug for BatchUpdateResult<E>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<E> Default for BatchUpdateResult<E>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more