[][src]Derive Macro diesel::associations::Identifiable

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

Implements Identifiable for references of the current type

By default, the primary key field is assumed to be a single field called id. If it's not, you can put #[primary_key(your_id)] on your struct. If you have a composite primary key, the syntax is #[primary_key(id1, id2)].

By default, #[derive(Identifiable)] will assume that your table name is the plural form of your struct name. Diesel uses very simple pluralization rules. It only adds an s to the end, and converts CamelCase to snake_case. If your table name does not follow this convention or the plural form isn't just an s, you can specify the table name with #[table_name = "some_table_name"]. 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; Our rules for inferring table names is considered public API. It will never change without a major version bump.

Attributes

Optional type attributes