Skip to content

Model Configuration

hasOne()

hasOne() — returns void

Available in: model Category: Association Functions

Sets up a hasOne association between this model and the specified one.

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).
joinTypestringnoouterUse to set the join type when joining associated tables. Possible values are inner (for INNER JOIN) and outer (for LEFT OUTER JOIN).
dependentstringnofalseDefines how to handle dependent model objects when you delete an object from this model. delete / deleteAll deletes the record(s) (deleteAll bypasses object instantiation). remove / removeAll sets the forein key field(s) to NULL (removeAll bypasses object instantiation).
asstringno—