Function
belongsTo (modelName, options) Ember.computed public
Module:
@ember-data/model
Defined in ../packages/model/src/-private/belongs-to.js:28
- modelName
- String
- (optional) type of the relationship
- options
- Object
- (optional) a hash of options
- returns
- Ember.computed
- relationship
belongsTo
is used to define One-To-One and One-To-Many
relationships on a Model.
belongsTo
takes an optional hash as a second parameter, currently
supported options are:
async
: A boolean value used to explicitly declare this to be an async relationship. The default is true.inverse
: A string used to identify the inverse property on a related model in a One-To-Many relationship. See Explicit Inversespolymorphic
A boolean value to mark the relationship as polymorphic
One-To-One
To declare a one-to-one relationship between two models, use
belongsTo
:
app/models/user.js | |
1 2 3 |
import Model, { belongsTo } from ' -data/model'; export default class UserModel extends Model { |