Trait rocket_db_pools::diesel::prelude::Insertable

source ·
pub trait Insertable<T> {
    type Values;

    // Required method
    fn values(self) -> Self::Values;

    // Provided method
    fn insert_into(self, table: T) -> InsertStatement<T, Self::Values>
       where T: Table,
             Self: Sized { ... }
}
Expand description

Represents that a structure can be used to insert a new row into the database. This is automatically implemented for &[T] and &Vec<T> for inserting more than one record.

This trait can be derived

Required Associated Types§

source

type Values

The VALUES clause to insert these records

The types used here are generally internal to Diesel. Implementations of this trait should use the Values type of other Insertable types. For example <diesel::dsl::Eq<column, &str> as Insertable<table>>::Values.

Required Methods§

source

fn values(self) -> Self::Values

Construct Self::Values

Implementations of this trait typically call .values on other Insertable types.

Provided Methods§

source

fn insert_into(self, table: T) -> InsertStatement<T, Self::Values>
where T: Table, Self: Sized,

Insert self into a given table.

foo.insert_into(table) is identical to insert_into(table).values(foo). However, when inserting from a select statement, this form is generally preferred.

§Example
users::table
    .select((
        users::name.concat("'s First Post"),
        users::id,
    ))
    .insert_into(posts::table)
    .into_columns((posts::title, posts::user_id))
    .execute(conn)?;

let inserted_posts = posts::table
    .select(posts::title)
    .load::<String>(conn)?;
let expected = vec!["Sean's First Post", "Tess's First Post"];
assert_eq!(expected, inserted_posts);

Implementations on Foreign Types§

source§

impl<'a, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, Tab> Insertable<Tab> for &'a (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)

source§

impl<'a, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, Tab> Insertable<Tab> for &'a (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)

source§

impl<'a, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, Tab> Insertable<Tab> for &'a (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)

source§

impl<'a, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, Tab> Insertable<Tab> for &'a (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)

source§

impl<'a, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, Tab> Insertable<Tab> for &'a (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)

source§

impl<'a, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, Tab> Insertable<Tab> for &'a (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)

source§

impl<'a, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, Tab> Insertable<Tab> for &'a (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)

source§

impl<'a, T0, T1, T2, T3, T4, T5, T6, T7, T8, Tab> Insertable<Tab> for &'a (T0, T1, T2, T3, T4, T5, T6, T7, T8)

source§

impl<'a, T0, T1, T2, T3, T4, T5, T6, T7, Tab> Insertable<Tab> for &'a (T0, T1, T2, T3, T4, T5, T6, T7)

source§

impl<'a, T0, T1, T2, T3, T4, T5, T6, Tab> Insertable<Tab> for &'a (T0, T1, T2, T3, T4, T5, T6)

source§

impl<'a, T0, T1, T2, T3, T4, T5, Tab> Insertable<Tab> for &'a (T0, T1, T2, T3, T4, T5)

source§

impl<'a, T0, T1, T2, T3, T4, Tab> Insertable<Tab> for &'a (T0, T1, T2, T3, T4)

source§

impl<'a, T0, T1, T2, T3, Tab> Insertable<Tab> for &'a (T0, T1, T2, T3)

source§

impl<'a, T0, T1, T2, Tab> Insertable<Tab> for &'a (T0, T1, T2)
where (&'a T0, &'a T1, &'a T2): Insertable<Tab>,

source§

impl<'a, T0, T1, Tab> Insertable<Tab> for &'a (T0, T1)
where (&'a T0, &'a T1): Insertable<Tab>,

source§

type Values = <(&'a T0, &'a T1) as Insertable<Tab>>::Values

source§

fn values(self) -> <&'a (T0, T1) as Insertable<Tab>>::Values

source§

impl<'a, T0, Tab> Insertable<Tab> for &'a (T0,)
where (&'a T0,): Insertable<Tab>,

source§

type Values = <(&'a T0,) as Insertable<Tab>>::Values

source§

fn values(self) -> <&'a (T0,) as Insertable<Tab>>::Values

source§

impl<'a, T, Tab> Insertable<Tab> for &'a Option<T>
where Option<&'a T>: Insertable<Tab>,

source§

type Values = <Option<&'a T> as Insertable<Tab>>::Values

source§

fn values(self) -> <&'a Option<T> as Insertable<Tab>>::Values

source§

impl<'a, T, Tab> Insertable<Tab> for &'a [T]

source§

type Values = BatchInsert<Vec<<&'a T as Insertable<Tab>>::Values>, Tab, (), false>

source§

fn values(self) -> <&'a [T] as Insertable<Tab>>::Values

source§

impl<'a, T, Tab> Insertable<Tab> for &'a Vec<T>
where &'a [T]: Insertable<Tab>,

source§

type Values = <&'a [T] as Insertable<Tab>>::Values

source§

fn values(self) -> <&'a Vec<T> as Insertable<Tab>>::Values

source§

impl<'a, T, Tab, const N: usize> Insertable<Tab> for &'a [T; N]
where T: Insertable<Tab>, &'a T: Insertable<Tab>,

source§

type Values = BatchInsert<Vec<<&'a T as Insertable<Tab>>::Values>, Tab, [<T as Insertable<Tab>>::Values; N], true>

source§

fn values(self) -> <&'a [T; N] as Insertable<Tab>>::Values

source§

impl<T0, ST0, Tab> Insertable<Tab> for (T0,)
where T0: Insertable<Tab, Values = ValuesClause<ST0, Tab>>,

source§

impl<T0, T1, ST0, ST1, Tab> Insertable<Tab> for (T0, T1)
where T0: Insertable<Tab, Values = ValuesClause<ST0, Tab>>, T1: Insertable<Tab, Values = ValuesClause<ST1, Tab>>,

source§

impl<T0, T1, T2, ST0, ST1, ST2, Tab> Insertable<Tab> for (T0, T1, T2)
where T0: Insertable<Tab, Values = ValuesClause<ST0, Tab>>, T1: Insertable<Tab, Values = ValuesClause<ST1, Tab>>, T2: Insertable<Tab, Values = ValuesClause<ST2, Tab>>,

source§

impl<T0, T1, T2, T3, ST0, ST1, ST2, ST3, Tab> Insertable<Tab> for (T0, T1, T2, T3)
where T0: Insertable<Tab, Values = ValuesClause<ST0, Tab>>, T1: Insertable<Tab, Values = ValuesClause<ST1, Tab>>, T2: Insertable<Tab, Values = ValuesClause<ST2, Tab>>, T3: Insertable<Tab, Values = ValuesClause<ST3, Tab>>,

source§

impl<T0, T1, T2, T3, T4, ST0, ST1, ST2, ST3, ST4, Tab> Insertable<Tab> for (T0, T1, T2, T3, T4)
where T0: Insertable<Tab, Values = ValuesClause<ST0, Tab>>, T1: Insertable<Tab, Values = ValuesClause<ST1, Tab>>, T2: Insertable<Tab, Values = ValuesClause<ST2, Tab>>, T3: Insertable<Tab, Values = ValuesClause<ST3, Tab>>, T4: Insertable<Tab, Values = ValuesClause<ST4, Tab>>,

source§

impl<T0, T1, T2, T3, T4, T5, ST0, ST1, ST2, ST3, ST4, ST5, Tab> Insertable<Tab> for (T0, T1, T2, T3, T4, T5)
where T0: Insertable<Tab, Values = ValuesClause<ST0, Tab>>, T1: Insertable<Tab, Values = ValuesClause<ST1, Tab>>, T2: Insertable<Tab, Values = ValuesClause<ST2, Tab>>, T3: Insertable<Tab, Values = ValuesClause<ST3, Tab>>, T4: Insertable<Tab, Values = ValuesClause<ST4, Tab>>, T5: Insertable<Tab, Values = ValuesClause<ST5, Tab>>,

source§

impl<T0, T1, T2, T3, T4, T5, T6, ST0, ST1, ST2, ST3, ST4, ST5, ST6, Tab> Insertable<Tab> for (T0, T1, T2, T3, T4, T5, T6)
where T0: Insertable<Tab, Values = ValuesClause<ST0, Tab>>, T1: Insertable<Tab, Values = ValuesClause<ST1, Tab>>, T2: Insertable<Tab, Values = ValuesClause<ST2, Tab>>, T3: Insertable<Tab, Values = ValuesClause<ST3, Tab>>, T4: Insertable<Tab, Values = ValuesClause<ST4, Tab>>, T5: Insertable<Tab, Values = ValuesClause<ST5, Tab>>, T6: Insertable<Tab, Values = ValuesClause<ST6, Tab>>,

source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, Tab> Insertable<Tab> for (T0, T1, T2, T3, T4, T5, T6, T7)
where T0: Insertable<Tab, Values = ValuesClause<ST0, Tab>>, T1: Insertable<Tab, Values = ValuesClause<ST1, Tab>>, T2: Insertable<Tab, Values = ValuesClause<ST2, Tab>>, T3: Insertable<Tab, Values = ValuesClause<ST3, Tab>>, T4: Insertable<Tab, Values = ValuesClause<ST4, Tab>>, T5: Insertable<Tab, Values = ValuesClause<ST5, Tab>>, T6: Insertable<Tab, Values = ValuesClause<ST6, Tab>>, T7: Insertable<Tab, Values = ValuesClause<ST7, Tab>>,

source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, ST8, Tab> Insertable<Tab> for (T0, T1, T2, T3, T4, T5, T6, T7, T8)
where T0: Insertable<Tab, Values = ValuesClause<ST0, Tab>>, T1: Insertable<Tab, Values = ValuesClause<ST1, Tab>>, T2: Insertable<Tab, Values = ValuesClause<ST2, Tab>>, T3: Insertable<Tab, Values = ValuesClause<ST3, Tab>>, T4: Insertable<Tab, Values = ValuesClause<ST4, Tab>>, T5: Insertable<Tab, Values = ValuesClause<ST5, Tab>>, T6: Insertable<Tab, Values = ValuesClause<ST6, Tab>>, T7: Insertable<Tab, Values = ValuesClause<ST7, Tab>>, T8: Insertable<Tab, Values = ValuesClause<ST8, Tab>>,

source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, ST8, ST9, Tab> Insertable<Tab> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)
where T0: Insertable<Tab, Values = ValuesClause<ST0, Tab>>, T1: Insertable<Tab, Values = ValuesClause<ST1, Tab>>, T2: Insertable<Tab, Values = ValuesClause<ST2, Tab>>, T3: Insertable<Tab, Values = ValuesClause<ST3, Tab>>, T4: Insertable<Tab, Values = ValuesClause<ST4, Tab>>, T5: Insertable<Tab, Values = ValuesClause<ST5, Tab>>, T6: Insertable<Tab, Values = ValuesClause<ST6, Tab>>, T7: Insertable<Tab, Values = ValuesClause<ST7, Tab>>, T8: Insertable<Tab, Values = ValuesClause<ST8, Tab>>, T9: Insertable<Tab, Values = ValuesClause<ST9, Tab>>,

source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, ST8, ST9, ST10, Tab> Insertable<Tab> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)
where T0: Insertable<Tab, Values = ValuesClause<ST0, Tab>>, T1: Insertable<Tab, Values = ValuesClause<ST1, Tab>>, T2: Insertable<Tab, Values = ValuesClause<ST2, Tab>>, T3: Insertable<Tab, Values = ValuesClause<ST3, Tab>>, T4: Insertable<Tab, Values = ValuesClause<ST4, Tab>>, T5: Insertable<Tab, Values = ValuesClause<ST5, Tab>>, T6: Insertable<Tab, Values = ValuesClause<ST6, Tab>>, T7: Insertable<Tab, Values = ValuesClause<ST7, Tab>>, T8: Insertable<Tab, Values = ValuesClause<ST8, Tab>>, T9: Insertable<Tab, Values = ValuesClause<ST9, Tab>>, T10: Insertable<Tab, Values = ValuesClause<ST10, Tab>>,

source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, ST8, ST9, ST10, ST11, Tab> Insertable<Tab> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)
where T0: Insertable<Tab, Values = ValuesClause<ST0, Tab>>, T1: Insertable<Tab, Values = ValuesClause<ST1, Tab>>, T2: Insertable<Tab, Values = ValuesClause<ST2, Tab>>, T3: Insertable<Tab, Values = ValuesClause<ST3, Tab>>, T4: Insertable<Tab, Values = ValuesClause<ST4, Tab>>, T5: Insertable<Tab, Values = ValuesClause<ST5, Tab>>, T6: Insertable<Tab, Values = ValuesClause<ST6, Tab>>, T7: Insertable<Tab, Values = ValuesClause<ST7, Tab>>, T8: Insertable<Tab, Values = ValuesClause<ST8, Tab>>, T9: Insertable<Tab, Values = ValuesClause<ST9, Tab>>, T10: Insertable<Tab, Values = ValuesClause<ST10, Tab>>, T11: Insertable<Tab, Values = ValuesClause<ST11, Tab>>,

source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, ST8, ST9, ST10, ST11, ST12, Tab> Insertable<Tab> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)
where T0: Insertable<Tab, Values = ValuesClause<ST0, Tab>>, T1: Insertable<Tab, Values = ValuesClause<ST1, Tab>>, T2: Insertable<Tab, Values = ValuesClause<ST2, Tab>>, T3: Insertable<Tab, Values = ValuesClause<ST3, Tab>>, T4: Insertable<Tab, Values = ValuesClause<ST4, Tab>>, T5: Insertable<Tab, Values = ValuesClause<ST5, Tab>>, T6: Insertable<Tab, Values = ValuesClause<ST6, Tab>>, T7: Insertable<Tab, Values = ValuesClause<ST7, Tab>>, T8: Insertable<Tab, Values = ValuesClause<ST8, Tab>>, T9: Insertable<Tab, Values = ValuesClause<ST9, Tab>>, T10: Insertable<Tab, Values = ValuesClause<ST10, Tab>>, T11: Insertable<Tab, Values = ValuesClause<ST11, Tab>>, T12: Insertable<Tab, Values = ValuesClause<ST12, Tab>>,

source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, ST8, ST9, ST10, ST11, ST12, ST13, Tab> Insertable<Tab> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)
where T0: Insertable<Tab, Values = ValuesClause<ST0, Tab>>, T1: Insertable<Tab, Values = ValuesClause<ST1, Tab>>, T2: Insertable<Tab, Values = ValuesClause<ST2, Tab>>, T3: Insertable<Tab, Values = ValuesClause<ST3, Tab>>, T4: Insertable<Tab, Values = ValuesClause<ST4, Tab>>, T5: Insertable<Tab, Values = ValuesClause<ST5, Tab>>, T6: Insertable<Tab, Values = ValuesClause<ST6, Tab>>, T7: Insertable<Tab, Values = ValuesClause<ST7, Tab>>, T8: Insertable<Tab, Values = ValuesClause<ST8, Tab>>, T9: Insertable<Tab, Values = ValuesClause<ST9, Tab>>, T10: Insertable<Tab, Values = ValuesClause<ST10, Tab>>, T11: Insertable<Tab, Values = ValuesClause<ST11, Tab>>, T12: Insertable<Tab, Values = ValuesClause<ST12, Tab>>, T13: Insertable<Tab, Values = ValuesClause<ST13, Tab>>,

source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, ST8, ST9, ST10, ST11, ST12, ST13, ST14, Tab> Insertable<Tab> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)
where T0: Insertable<Tab, Values = ValuesClause<ST0, Tab>>, T1: Insertable<Tab, Values = ValuesClause<ST1, Tab>>, T2: Insertable<Tab, Values = ValuesClause<ST2, Tab>>, T3: Insertable<Tab, Values = ValuesClause<ST3, Tab>>, T4: Insertable<Tab, Values = ValuesClause<ST4, Tab>>, T5: Insertable<Tab, Values = ValuesClause<ST5, Tab>>, T6: Insertable<Tab, Values = ValuesClause<ST6, Tab>>, T7: Insertable<Tab, Values = ValuesClause<ST7, Tab>>, T8: Insertable<Tab, Values = ValuesClause<ST8, Tab>>, T9: Insertable<Tab, Values = ValuesClause<ST9, Tab>>, T10: Insertable<Tab, Values = ValuesClause<ST10, Tab>>, T11: Insertable<Tab, Values = ValuesClause<ST11, Tab>>, T12: Insertable<Tab, Values = ValuesClause<ST12, Tab>>, T13: Insertable<Tab, Values = ValuesClause<ST13, Tab>>, T14: Insertable<Tab, Values = ValuesClause<ST14, Tab>>,

source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, ST8, ST9, ST10, ST11, ST12, ST13, ST14, ST15, Tab> Insertable<Tab> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)
where T0: Insertable<Tab, Values = ValuesClause<ST0, Tab>>, T1: Insertable<Tab, Values = ValuesClause<ST1, Tab>>, T2: Insertable<Tab, Values = ValuesClause<ST2, Tab>>, T3: Insertable<Tab, Values = ValuesClause<ST3, Tab>>, T4: Insertable<Tab, Values = ValuesClause<ST4, Tab>>, T5: Insertable<Tab, Values = ValuesClause<ST5, Tab>>, T6: Insertable<Tab, Values = ValuesClause<ST6, Tab>>, T7: Insertable<Tab, Values = ValuesClause<ST7, Tab>>, T8: Insertable<Tab, Values = ValuesClause<ST8, Tab>>, T9: Insertable<Tab, Values = ValuesClause<ST9, Tab>>, T10: Insertable<Tab, Values = ValuesClause<ST10, Tab>>, T11: Insertable<Tab, Values = ValuesClause<ST11, Tab>>, T12: Insertable<Tab, Values = ValuesClause<ST12, Tab>>, T13: Insertable<Tab, Values = ValuesClause<ST13, Tab>>, T14: Insertable<Tab, Values = ValuesClause<ST14, Tab>>, T15: Insertable<Tab, Values = ValuesClause<ST15, Tab>>,

source§

impl<T, Tab> Insertable<Tab> for Vec<T>
where T: Insertable<Tab> + UndecoratedInsertRecord<Tab>,

source§

type Values = BatchInsert<Vec<<T as Insertable<Tab>>::Values>, Tab, (), false>

source§

fn values(self) -> <Vec<T> as Insertable<Tab>>::Values

source§

impl<T, Tab, V> Insertable<Tab> for Option<T>
where T: Insertable<Tab, Values = ValuesClause<V, Tab>>, InsertableOptionHelper<T, V>: Insertable<Tab>,

source§

type Values = <InsertableOptionHelper<T, V> as Insertable<Tab>>::Values

source§

fn values(self) -> <Option<T> as Insertable<Tab>>::Values

source§

impl<T, Tab, const N: usize> Insertable<Tab> for [T; N]
where T: Insertable<Tab>,

source§

type Values = BatchInsert<Vec<<T as Insertable<Tab>>::Values>, Tab, [<T as Insertable<Tab>>::Values; N], true>

source§

fn values(self) -> <[T; N] as Insertable<Tab>>::Values

source§

impl<T, Tab, const N: usize> Insertable<Tab> for Box<[T; N]>
where T: Insertable<Tab>,

source§

type Values = BatchInsert<Vec<<T as Insertable<Tab>>::Values>, Tab, [<T as Insertable<Tab>>::Values; N], true>

source§

fn values(self) -> <Box<[T; N]> as Insertable<Tab>>::Values

Implementors§

source§

impl<'a, 'b, ST, QS, DB, T, GB> Insertable<T> for &'b BoxedSelectStatement<'a, ST, QS, DB, GB>
where T: Table, &'b BoxedSelectStatement<'a, ST, QS, DB, GB>: Query, <<T as Table>::AllColumns as ValidGrouping<()>>::IsAggregate: MixedAggregates<No, Output = No>,

source§

type Values = InsertFromSelect<&'b BoxedSelectStatement<'a, ST, QS, DB, GB>, <T as Table>::AllColumns>

source§

impl<'a, F, S, D, W, O, LOf, G, H, LC, Tab> Insertable<Tab> for &'a SelectStatement<F, S, D, W, O, LOf, G, H, LC>
where Tab: Table, &'a SelectStatement<F, S, D, W, O, LOf, G, H, LC>: Query, <<Tab as Table>::AllColumns as ValidGrouping<()>>::IsAggregate: MixedAggregates<No, Output = No>,

source§

type Values = InsertFromSelect<&'a SelectStatement<F, S, D, W, O, LOf, G, H, LC>, <Tab as Table>::AllColumns>

source§

impl<'a, ST, QS, DB, T, GB> Insertable<T> for BoxedSelectStatement<'a, ST, QS, DB, GB>
where T: Table, BoxedSelectStatement<'a, ST, QS, DB, GB>: Query, <<T as Table>::AllColumns as ValidGrouping<()>>::IsAggregate: MixedAggregates<No, Output = No>,

source§

type Values = InsertFromSelect<BoxedSelectStatement<'a, ST, QS, DB, GB>, <T as Table>::AllColumns>

source§

impl<F, S, D, W, O, LOf, G, H, LC, Tab> Insertable<Tab> for SelectStatement<F, S, D, W, O, LOf, G, H, LC>
where Tab: Table, SelectStatement<F, S, D, W, O, LOf, G, H, LC>: Query, <<Tab as Table>::AllColumns as ValidGrouping<()>>::IsAggregate: MixedAggregates<No, Output = No>,

source§

type Values = InsertFromSelect<SelectStatement<F, S, D, W, O, LOf, G, H, LC>, <Tab as Table>::AllColumns>