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:

app/models/post.js
import DS from 'ember-data';

export default DS.Model.extend({
  comments: DS.hasMany('comment')
});
app/models/comment.js
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.

Show:

Module: ember-data

Reloads all of the records in the manyArray. If the manyArray holds a relationship that was originally fetched using a links url Ember Data will revisit the original links url to repopulate the relationship.

If the manyArray holds the result of a store.query() reload will re-run the original query.

Example

var user = store.peekRecord('user', 1)
user.login().then(function() {
  user.get('permissions').then(function(permissions) {
    return permissions.reload();
  });
});
Module: ember-data
returns
DS.PromiseArray

promise

Saves all of the records in the ManyArray.

Example

store.findRecord('inbox', 1).then(function(inbox) {
  inbox.get('messages').then(function(messages) {
    messages.forEach(function(message) {
      message.set('isRead', true);
    });
    messages.save()
  });
});