Mixin BelongsTo
One-to-one association
In the API reference below, replace Assocation
with the actual name of your association, e.g. for User.belongsTo(Project)
the getter will be user.getProject()
.
getAssociation([options]) -> Promise.<Instance>
Get the associated instance.
Params:
Name | Type | Description |
---|---|---|
[options] | Object | |
[options.scope] | String | Boolean | Apply a scope on the related model, or remove its default scope by passing false. |
[options.schema] | String | Apply a schema on the related model |
setAssociation([newAssociation], [options]) -> Promise
Set the associated model.
Params:
Name | Type | Description |
---|---|---|
[newAssociation] | Instance | String | Number | An persisted instance or the primary key of an instance to associate with this. Pass null or undefined to remove the association. |
[options] | Object | Options passed to this.save |
[options.save=true] | Boolean | Skip saving this after setting the foreign key if false. |
createAssociation([values], [options]) -> Promise
Create a new instance of the associated model and associate it with this.
Params:
Name | Type | Description |
---|---|---|
[values] | Object | |
[options] | Object | Options passed to target.create and setAssociation. |
This document is automatically generated based on source code comments. Please do not edit it directly, as your changes will be ignored. Please write on IRC, open an issue or a create a pull request if you feel something can be improved. For help on how to write source code documentation see JSDoc and dox