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]

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: Copy, U: Copy, Op: Copy, Ret: Copy> Copy for BatchInsertStatement<T, U, Op, Ret>
[src]

impl<T: Clone, U: Clone, Op: Clone, Ret: Clone> Clone for BatchInsertStatement<T, U, Op, Ret>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<T: Debug, U: Debug, Op: Debug, Ret: Debug> Debug for BatchInsertStatement<T, U, Op, Ret>
[src]

Formats the value using the given formatter.

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]

Executes the given command, returning the number of rows affected. Used in conjunction with update and delete Read more

impl<'a, T, U, Op, Ret> ExecuteDsl<SqliteConnection> for BatchInsertStatement<T, &'a [U], Op, Ret> where InsertStatement<T, &'a U, Op, Ret>: ExecuteDsl<SqliteConnection>,
        T: Copy,
        Op: Copy,
        Ret: Copy
[src]

Executes the given command, returning the number of rows affected. Used in conjunction with update and delete Read more

impl<'a, T, U, Op, Ret, Conn, ST> LoadDsl<Conn> for BatchInsertStatement<T, &'a [U], Op, Ret> where Conn: Connection,
        Conn::Backend: HasSqlType<ST>,
        InsertStatement<T, &'a [U], Op, Ret>: LoadDsl<Conn, SqlType=ST>
[src]

Executes the given query, returning an Iterator over the returned rows. Read more

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

Attempts to load a single record. Returns Ok(record) if found, and Err(NotFound) if no results are returned. If the query truly is optional, you can call .optional() on the result of this to get a Result<Option<U>>. Read more

Runs the command, returning an Iterator over the affected rows.