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

#[derive(AsChangeset)]
{
    // Attributes available to this derive:
    #[table_name]
    #[primary_key]
    #[column_name]
    #[changeset_options]
}

Implements AsChangeset

To implement AsChangeset 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"].

By default, any Option fields on the struct are skipped if their value is None. If you would like to assign NULL to the field instead, you can annotate your struct with #[changeset_options(treat_none_as_null = "true")].

Attributes

Optional type attributes

Optional field attributes