[][src]Derive Macro diesel::prelude::Insertable

#[derive(Insertable)]
{
    // Attributes available to this derive:
    #[table_name]
    #[column_name]
    #[diesel]
}

Implements Insertable

To implement Insertable this derive needs to know the corresponding table type. By default it uses the snake_case type name with an added s. It is possible to change this default by using #[table_name = "something"]. In both cases the module for that table must be in scope. For example, to derive this for a struct called User, you will likely need a line such as use schema::users;

If a field name of your struct differs from the name of the corresponding column, you can annotate the field with #[column_name = "some_column_name"].

Your struct can also contain fields which implement Insertable. This is useful when you want to have one field map to more than one column (for example, an enum that maps to a label and a value column). Add #[diesel(embed)] to any such fields.

Attributes

Optional type attributes

Optional field attributes