Class DS.ManyArray
A ManyArray
is a MutableArray
that represents the contents of a has-many
relationship.
The ManyArray
is instantiated lazily the first time the relationship is
requested.
Inverses
Often, the relationships in Ember Data applications will have an inverse. For example, imagine the following models are defined:
import DS from 'ember-data';
export default DS.Model.extend({
comments: DS.hasMany('comment')
});
import DS from 'ember-data';
export default DS.Model.extend({
post: DS.belongsTo('post')
});
If you created a new instance of App.Post
and added
a App.Comment
record to its comments
has-many
relationship, you would expect the comment's post
property to be set to the post that contained
the has-many.
We call the record to which a relationship belongs the relationship's owner.
isLoaded
Defined in addon/-private/system/many-array.js:61
The loading state of this array
meta public
Defined in addon/-private/system/many-array.js:78
Metadata associated with the request for async hasMany relationships.
Example
Given that the server returns the following JSON payload when fetching a hasMany relationship:
{
"comments": [{
"id": 1,
"comment": "This is the first comment",
}, {
// ...
}],
"meta": {
"page": 1,
"total": 5
}
}
You can then access the metadata via the meta
property:
post.get('comments').then(function(comments) {
var meta = comments.get('meta');
// meta.page => 1
// meta.total => 5
});