home
  • Blog
  • Home
  • Projects
    • Ember
    • EmberData
    • Ember CLI
1.13
  • Packages
    • ember-data
  • Namespaces
    • DS
    • Ember.Date
  • Classes
    • DS.AbortError
    • DS.ActiveModelAdapter
    • DS.ActiveModelSerializer
    • DS.Adapter
    • DS.AdapterError
    • DS.AdapterPopulatedRecordArray
    • DS.BooleanTransform
    • DS.BuildURLMixin
    • DS.DateTransform
    • DS.EmbeddedRecordsMixin
    • DS.Errors
    • DS.FilteredRecordArray
    • DS.FixtureAdapter
    • DS.InternalModel
    • DS.InvalidError
    • DS.JSONAPIAdapter
    • DS.JSONAPISerializer
    • DS.JSONSerializer
    • DS.ManyArray
    • DS.Model
    • DS.NumberTransform
    • DS.PromiseArray
    • DS.PromiseManyArray
    • DS.PromiseObject
    • DS.RESTAdapter
    • DS.RESTSerializer
    • DS.RecordArray
    • DS.RootState
    • DS.Serializer
    • DS.Store
    • DS.StringTransform
    • DS.TimeoutError
    • DS.Transform

Class DS.ManyArray


Extends: Ember.Object
Uses: Ember.Evented , Ember.MutableArray
Defined in: packages/ember-data/lib/system/many-array.js:11
Module: ember-data

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.


Methods

reload public

Module: ember-data

Defined in packages/ember-data/lib/system/many-array.js:231

save : DS.PromiseArray

Module: ember-data

Defined in packages/ember-data/lib/system/many-array.js:239

returns
DS.PromiseArray

promise

Saves all of the records in the ManyArray.

Example

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

Properties

isLoaded

Module: ember-data

Defined in packages/ember-data/lib/system/many-array.js:103

The loading state of this array

meta public

Module: ember-data

Defined in packages/ember-data/lib/system/many-array.js:118

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
});
On this page


Methods

  • reload
  • save

Properties

  • isLoaded
  • meta
Team Sponsors Security Legal Branding Community Guidelines
Twitter GitHub Discord Mastodon

If you want help you can contact us by email, open an issue, or get realtime help by joining the Ember Discord.

© Copyright 2025 - Tilde Inc.
Ember.js is free, open source and always will be.


Ember is generously supported by
blue Created with Sketch.