Struct diesel::query_builder::insert_statement::BatchInsertStatement
[−]
[src]
pub struct BatchInsertStatement<T, U, Op = Insert, Ret = NoReturningClause> { /* fields omitted */ }
The result of calling insert(records).into(some_table)
when records
is
a slice or a Vec
. When calling methods from ExecuteDsl
or LoadDsl
.
When the given slice is empty, this struct will not execute any queries.
When the given slice is not empty, this will execute a single bulk insert
on backends which support the DEFAULT
keyword, and one query per record
on backends which do not (SQLite).
Methods
impl<T, U, Op> BatchInsertStatement<T, U, Op>
[src]
fn returning<E>(
self,
returns: E
) -> BatchInsertStatement<T, U, Op, ReturningClause<E>>
[src]
self,
returns: E
) -> BatchInsertStatement<T, U, Op, ReturningClause<E>>
Specify what expression is returned after execution of the insert
.
Examples
Inserting records:
let new_users = vec![ NewUser { name: "Timmy".to_string(), }, NewUser { name: "Jimmy".to_string(), }, ]; let inserted_names = diesel::insert(&new_users) .into(users) .returning(name) .get_results(&connection); assert_eq!(Ok(vec!["Timmy".to_string(), "Jimmy".to_string()]), inserted_names);
Trait Implementations
impl<T: Debug, U: Debug, Op: Debug, Ret: Debug> Debug for BatchInsertStatement<T, U, Op, Ret>
[src]
impl<T: Clone, U: Clone, Op: Clone, Ret: Clone> Clone for BatchInsertStatement<T, U, Op, Ret>
[src]
fn clone(&self) -> BatchInsertStatement<T, U, Op, Ret>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: Copy, U: Copy, Op: Copy, Ret: Copy> Copy for BatchInsertStatement<T, U, Op, Ret>
[src]
impl<'a, T, U, Op, Ret, Conn, DB> ExecuteDsl<Conn, DB> for BatchInsertStatement<T, &'a [U], Op, Ret> where
Conn: Connection<Backend = DB>,
DB: Backend + SupportsDefaultKeyword,
InsertStatement<T, &'a [U], Op, Ret>: ExecuteDsl<Conn>,
[src]
Conn: Connection<Backend = DB>,
DB: Backend + SupportsDefaultKeyword,
InsertStatement<T, &'a [U], Op, Ret>: ExecuteDsl<Conn>,
fn execute(self, conn: &Conn) -> QueryResult<usize>
[src]
Executes the given command, returning the number of rows affected. Used in conjunction with update
and delete
Read more
impl<'a, T, U, V, Op, Ret, Conn> LoadQuery<Conn, V> for BatchInsertStatement<T, &'a [U], Op, Ret> where
InsertStatement<T, &'a [U], Op, Ret>: LoadQuery<Conn, V>,
[src]
InsertStatement<T, &'a [U], Op, Ret>: LoadQuery<Conn, V>,
fn internal_load(self, conn: &Conn) -> QueryResult<Vec<V>>
[src]
impl<'a, T, U, Op, Ret, Conn> LoadDsl<Conn> for BatchInsertStatement<T, &'a [U], Op, Ret>
[src]
fn load<U>(self, conn: &Conn) -> QueryResult<Vec<U>> where
Self: LoadQuery<Conn, U>,
[src]
Self: LoadQuery<Conn, U>,
Executes the given query, returning a Vec
with the returned rows.
fn get_result<U>(self, conn: &Conn) -> QueryResult<U> where
Self: LoadQuery<Conn, U>,
[src]
Self: LoadQuery<Conn, U>,
Runs the command, and returns the affected row. Err(NotFound)
will be returned if the query affected 0 rows. You can call .optional()
on the result of this if the command was optional to get back a Result<Option<U>>
Read more
fn get_results<U>(self, conn: &Conn) -> QueryResult<Vec<U>> where
Self: LoadQuery<Conn, U>,
[src]
Self: LoadQuery<Conn, U>,
Runs the command, returning an Vec
with the affected rows.