# HasMany's ManyArray

**URL:** https://discuss.emberjs.com/t/hasmanys-manyarray/11044
**Category:** Ember Data
**Created:** [June 30, 2016, 7:22pm UTC](https://discuss.emberjs.com/t/hasmanys-manyarray/11044 "2016-06-30T19:22:26Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![onsmith](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/onsmith/32/13462_2.png) [@onsmith](https://discuss.emberjs.com/u/onsmith)
#### Post date: [June 30, 2016, 7:22pm UTC](https://discuss.emberjs.com/t/hasmanys-manyarray/11044/1 "2016-06-30T19:22:26Z")

</div>

What is the difference between these two usages of `ManyArray`? Is one more correct than the other? Does it matter?

```auto
//app/models/post.js
export default DS.Model.extend({
  comments: DS.hasMany('comment')
});

//app/models/comment.js
export default DS.Model.extend({
  post: DS.belongsTo('post')
});

// Usage 1: Access a post's comments directly
post.get('comments.length');
post.get('comments').forEach((comment) => {
    // Do something with comment here
});
post.get('comments').pushObject(pushThisComment);
post.get('comments').removeAt(removeTheCommentAtThisIndex);

// Usage 2: Access a post's comments after promise resolves
post.get('comments').then((comments) => {
    comments.get('length');
    comments.forEach((comment) => {
        // Do something with comment here
    });
    comments.pushObject(pushThisComment);
    comments.removeAt(removeTheCommentAtThisIndex);
});

```

---

<div class="post-metadata">

### Author: ![Diahron\_Grismore](https://avatars.discourse-cdn.com/v4/letter/d/edb3f5/32.png) [@Diahron\_Grismore](https://discuss.emberjs.com/u/Diahron_Grismore)
#### Post date: [June 30, 2016, 9:05pm UTC](https://discuss.emberjs.com/t/hasmanys-manyarray/11044/2 "2016-06-30T21:05:48Z")

</div>

Yes it does matter. Here’s a link to check out: [Relationships - Models - Ember Guides](https://guides.emberjs.com/v2.6.0/models/relationships/#toc_many-to-many) In the first usage your program cannot continue until this process finish. The second usage causes the program to work in the background, gathering all the data first, letting other processes continue. When the second has received all data it resumes.(keeping it’s promise to return a value.)

---

<div class="post-metadata">

### Author: ![onsmith](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/onsmith/32/13462_2.png) [@onsmith](https://discuss.emberjs.com/u/onsmith)
#### Post date: [June 30, 2016, 9:35pm UTC](https://discuss.emberjs.com/t/hasmanys-manyarray/11044/3 "2016-06-30T21:35:40Z")

</div>

So both methods yield the exact same result, and the only difference is that the first usage is synchronous while the second is asynchronous?
