Skip to content

Model Configuration

belongsTo()

belongsTo() — returns void

Available in: model Category: Association Functions

Sets up a belongsTo association between this model and the specified one. Use this association when this model contains a foreign key referencing another model.

NameTypeRequiredDefaultDescription
namestringyes—Gives the association a name that you refer to when working with the association (in the include argument to findAll, to name one example).
modelNamestringno—Name of associated model (usually not needed if you follow Wheels conventions because the model name will be deduced from the name argument).
foreignKeystringno—Foreign key property name (usually not needed if you follow Wheels conventions since the foreign key name will be deduced from the name argument).
joinKeystringno—Column name to join to if not the primary key (usually not needed if you follow Wheels conventions since the join key will be the table’s primary key/keys).
joinTypestringnoinnerUse to set the join type when joining associated tables. Possible values are inner (for INNER JOIN) and outer (for LEFT OUTER JOIN).
polymorphicbooleannofalse