has-one.md
2.28 KB
Mixin HasOne
View code One-to-one association
In the API reference below, replace Assocation(s)
with the actual name of your association, e.g. for User.belongsToMany(Project)
the getter will be user.getProjects()
.
getAssociation([options])
-> Promise.<Instance>
View code 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 |
setAssociation([newAssociations], [options])
-> Promise
View code Set the associated model
Params:
Name | Type | Description |
---|---|---|
[newAssociations] | Instance | String | Number | An array of instances or primary key of instances to associate with this. Pass null or undefined to remove all associations. |
[options] | Object | Options passed to getAssocation and target.save
|
createAssociation([values], [options])
-> Promise
View code 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