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

    // Attributes available to this derive:
Expand description

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 is in scope and its 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 is not in scope, you can specify a path to the table with #[table_name = "path::to::table"]. Our rules for inferring table names is considered public API. It will never change without a major version bump.


Optional container attributes

  • #[table_name = "path::to::table"] specifies a path to the table this type belongs to. The path is relative to the current module. If this attribute is not used, the type name converted to snake_case with an added s is used as table name
  • #[primary_key(id1, id2)] to specify the struct field that that corresponds to the primary key. If not used, id will be assumed as primary key field