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

    // Attributes available to this derive:
Expand description

Implement required traits for the associations API

This derive implement support for diesels associations api. Check the module level documentation of the diesel::associations module for details.


Required container attributes

  • #[belongs_to(User)], to specify a child-to-parent relation ship between the current type and the specified parent type (User). If this attribute is given multiple times, multiple relation ships are generated.
  • #[belongs_to(User, foreign_key = "mykey")], variant of the attribute above. Allows to specify the name of the foreign key. If the foreign key is not specified explicitly, the remote lower case type name with an appended _id is used as foreign key name. (user_id in this example case)

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.

Optional field attributes

  • #[column_name = "some_column_name"], overrides the column the current field maps to to some_column_name. By default the field name is used as column name. Only useful for the foreign key field.