pub struct TryInsert<A>where
    A: ActiveModelTrait,{ /* private fields */ }
Expand description

Performs INSERT operations on a ActiveModel, will do nothing if input is empty.

All functions works the same as if it is Insert. Please refer to Insert page for more information

Implementations§

§

impl<A> TryInsert<A>where A: ActiveModelTrait,

pub async fn exec<'a, C>( self, db: &'a C ) -> Result<TryInsertResult<InsertResult<A>>, DbErr>where C: ConnectionTrait, A: 'a,

Execute an insert operation

pub async fn exec_without_returning<'a, C>( self, db: &'a C ) -> Result<TryInsertResult<u64>, DbErr>where <<A as ActiveModelTrait>::Entity as EntityTrait>::Model: IntoActiveModel<A>, C: ConnectionTrait, A: 'a,

Execute an insert operation without returning (don’t use RETURNING syntax) Number of rows affected is returned

pub async fn exec_with_returning<'a, C>( self, db: &'a C ) -> Result<TryInsertResult<<<A as ActiveModelTrait>::Entity as EntityTrait>::Model>, DbErr>where <<A as ActiveModelTrait>::Entity as EntityTrait>::Model: IntoActiveModel<A>, C: ConnectionTrait, A: 'a,

Execute an insert operation and return the inserted model (use RETURNING syntax if supported)

§

impl<A> TryInsert<A>where A: ActiveModelTrait,

pub fn one<M>(m: M) -> TryInsert<A>where M: IntoActiveModel<A>,

pub fn many<M, I>(models: I) -> TryInsert<A>where M: IntoActiveModel<A>, I: IntoIterator<Item = M>,

pub fn add<M>(self, m: M) -> TryInsert<A>where M: IntoActiveModel<A>,

pub fn add_many<M, I>(self, models: I) -> TryInsert<A>where M: IntoActiveModel<A>, I: IntoIterator<Item = M>,

pub fn on_conflict(self, on_conflict: OnConflict) -> TryInsert<A>

pub fn from_insert(insert: Insert<A>) -> TryInsert<A>

Trait Implementations§

§

impl<A> Debug for TryInsert<A>where A: Debug + ActiveModelTrait,

§

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

Formats the value using the given formatter. Read more
§

impl<A> Default for TryInsert<A>where A: ActiveModelTrait,

§

fn default() -> TryInsert<A>

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

impl<A> QueryTrait for TryInsert<A>where A: ActiveModelTrait,

§

type QueryStatement = InsertStatement

Constrain the QueryStatement to QueryStatementBuilder trait
§

fn query(&mut self) -> &mut InsertStatement

Get a mutable ref to the query builder
§

fn as_query(&self) -> &InsertStatement

Get an immutable ref to the query builder
§

fn into_query(self) -> InsertStatement

Take ownership of the query builder
§

fn build(&self, db_backend: DatabaseBackend) -> Statement

Build the query as Statement
§

fn apply_if<T, F>(self, val: Option<T>, if_some: F) -> Selfwhere Self: Sized, F: FnOnce(Self, T) -> Self,

Apply an operation on the QueryTrait::QueryStatement if the given Option<T> is Some(_) Read more

Auto Trait Implementations§

§

impl<A> !RefUnwindSafe for TryInsert<A>

§

impl<A> Send for TryInsert<A>where A: Send,

§

impl<A> Sync for TryInsert<A>where A: Sync,

§

impl<A> Unpin for TryInsert<A>where A: Unpin,

§

impl<A> !UnwindSafe for TryInsert<A>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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 Twhere 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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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 Twhere U: TryFrom<T>,

§

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

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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