Trait diesel::prelude::Insertable
[−]
[src]
pub trait Insertable<T: Table, DB: Backend> { type Values: InsertValues<DB>; fn values(self) -> Self::Values; }
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.
Deriving
This trait can be automatically derived using diesel_codegen
by adding
#[derive(Insertable)]
to your struct. Structs which derive this trait must
also be annotated with #[table_name = "some_table_name"]
. If the field
name of your struct differs from the name of the column, you can annotate
the field with #[column_name = "some_column_name"]
.
Associated Types
type Values: InsertValues<DB>
Required Methods
Implementors
impl<Iter, T, DB> Insertable<T, DB> for Iter where
T: Table,
DB: Backend + SupportsDefaultKeyword,
Iter: IntoIterator,
Iter::Item: Insertable<T, DB>,
Iter::IntoIter: Clone, type Values = BatchInsertValues<Map<Iter::IntoIter, fn(_: Iter::Item) -> <Iter::Item as Insertable<T, DB>>::Values>>;impl<'a, T, Tab> Insertable<Tab, Pg> for &'a OnConflictDoNothing<T> where
Tab: Table,
T: Insertable<Tab, Pg> + Copy,
T: UndecoratedInsertRecord<Tab>, type Values = OnConflictValues<T::Values, NoConflictTarget, DoNothing>;impl<'a, Records, Target, Action, Tab> Insertable<Tab, Pg> for &'a OnConflict<Records, Target, Action> where
Tab: Table,
Records: Insertable<Tab, Pg> + Copy,
Records: UndecoratedInsertRecord<Tab>,
Target: OnConflictTarget<Tab> + Clone,
Action: IntoConflictAction<Tab> + Copy, type Values = OnConflictValues<Records::Values, Target, Action::Action>;impl<'a, 'insert, DB> Insertable<table, DB> for &'insert NewMigration<'a> where
DB: Backend,
(ColumnInsertValue<version, AsExpr<&'insert &'a str, version>>,): InsertValues<DB>, type Values = (ColumnInsertValue<version, AsExpr<&'insert &'a str, version>>,);