pub struct InsertMany<'a, M> { /* private fields */ }Expand description
An INSERT of whole records, created with Model::insert_many.
Generated columns are skipped and timestamps are set to now().
Implementations§
Source§impl<'a, M> InsertMany<'a, M>where
M: Model,
impl<'a, M> InsertMany<'a, M>where
M: Model,
Sourcepub fn on_conflict(
self,
columns: impl IntoIterator<Item = Column<M>>,
) -> InsertMany<'a, M>
pub fn on_conflict( self, columns: impl IntoIterator<Item = Column<M>>, ) -> InsertMany<'a, M>
Handle conflicts on these columns (a unique index or the primary
key). Follow with do_nothing,
do_update or
do_update_all.
Sourcepub fn on_constraint(self, name: &'static str) -> InsertMany<'a, M>
pub fn on_constraint(self, name: &'static str) -> InsertMany<'a, M>
Handle conflicts on the named constraint.
Sourcepub fn do_nothing(self) -> InsertMany<'a, M>
pub fn do_nothing(self) -> InsertMany<'a, M>
ON CONFLICT … DO NOTHING: skip conflicting rows. Without
on_conflict, any conflict is ignored.
Sourcepub fn do_update(
self,
columns: impl IntoIterator<Item = Column<M>>,
) -> InsertMany<'a, M>
pub fn do_update( self, columns: impl IntoIterator<Item = Column<M>>, ) -> InsertMany<'a, M>
ON CONFLICT … DO UPDATE setting these columns from the new row.
Sourcepub fn do_update_all(self) -> InsertMany<'a, M>
pub fn do_update_all(self) -> InsertMany<'a, M>
ON CONFLICT … DO UPDATE setting every inserted column except the
conflict columns, the primary key and created_at. With
on_constraint the constraint’s columns
aren’t known, so they are rewritten with their (equal) new values.
Sourcepub fn to_sql(&self) -> Sql
pub fn to_sql(&self) -> Sql
Render the INSERT statement. An incomplete ON CONFLICT
configuration is left out here and reported by exec.
Sourcepub async fn exec<'e, E>(self, executor: E) -> Result<Vec<M>, Error>where
E: Executor<'e>,
pub async fn exec<'e, E>(self, executor: E) -> Result<Vec<M>, Error>where
E: Executor<'e>,
Run the insert and return the stored rows. Rows skipped by
ON CONFLICT … DO NOTHING are not returned.
Every record is validated and passed to before_insert first; each
returned row is passed to after_insert.
Trait Implementations§
Source§impl<M> Clone for InsertMany<'_, M>
impl<M> Clone for InsertMany<'_, M>
Source§fn clone(&self) -> InsertMany<'_, M>
fn clone(&self) -> InsertMany<'_, M>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<'a, M> Freeze for InsertMany<'a, M>
impl<'a, M> RefUnwindSafe for InsertMany<'a, M>where
&'a [M]: RefUnwindSafe,
impl<'a, M> Send for InsertMany<'a, M>
impl<'a, M> Sync for InsertMany<'a, M>
impl<'a, M> Unpin for InsertMany<'a, M>
impl<'a, M> UnsafeUnpin for InsertMany<'a, M>where
&'a [M]: UnsafeUnpin,
impl<'a, M> UnwindSafe for InsertMany<'a, M>where
&'a [M]: 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
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> ⓘ
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