Struct diesel::query_builder::insert_statement::InsertStatement [] [src]

pub struct InsertStatement<T, U> {
    // some fields omitted
}

Methods

impl<T, U> InsertStatement<T, U>
[src]

fn returning<E>(self, returns: E) -> InsertQuery<E, InsertStatement<T, U>> where E: Expression, InsertQuery<E, InsertStatement<T, U>>: Query

Specify what expression is returned after execution of the insert.

Examples

Inserting a record:

let new_user = NewUser {
    name: "Timmy".to_string(),
};

let inserted_name = diesel::insert(&new_user)
    .into(users)
    .returning(name)
    .get_result(&connection);
assert_eq!(Ok("Timmy".to_string()), inserted_name);

Trait Implementations

impl<T, U, DB> QueryFragment<DB> for InsertStatement<T, U> where DB: Backend, T: Table, T::FromClause: QueryFragment<DB>, U: Insertable<T, DB> + Copy
[src]

fn to_sql(&self, out: &mut DB::QueryBuilder) -> BuildQueryResult

impl<T, U> AsQuery for InsertStatement<T, U> where T: Table, InsertQuery<T::AllColumns, InsertStatement<T, U>>: Query
[src]

type SqlType = Self::Query::SqlType

type Query = InsertQuery<T::AllColumns, InsertStatement<T, U>>

fn as_query(self) -> Self::Query