# Loading all the associations in a set in a single request

**URL:** <https://discuss.emberjs.com/t/loading-all-the-associations-in-a-set-in-a-single-request/3054>\
**Category:** Ember Data\
**Created:** [October 23, 2013, 6:56pm UTC](https://discuss.emberjs.com/t/loading-all-the-associations-in-a-set-in-a-single-request/3054 "2013-10-23T18:56:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lukegalea](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/lukegalea/32/4306_2.png) [@lukegalea](https://discuss.emberjs.com/u/lukegalea)\
**Post date:** [October 23, 2013, 6:56pm UTC](https://discuss.emberjs.com/t/loading-all-the-associations-in-a-set-in-a-single-request/3054/1 "2013-10-23T18:56:05Z")

</div>

How does one load hasMany associations for an entire set at once?

Given User who hasMany Memberships, if the User json payload includes membership\_ids for each… It’s trivial to grab a single user and get memberships, which makes a request with ids=1,2,3,4,etc

But how does once combine all the membership requests for the entire set of users to request the memberships in a single request?

I was hoping for something like this.get(‘users.@each.memberships’).then(…) but alas, that’s no good.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![daliwali](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/daliwali/32/15185_2.png) [@daliwali](https://discuss.emberjs.com/u/daliwali)\
**Post date:** [October 23, 2013, 8:07pm UTC](https://discuss.emberjs.com/t/loading-all-the-associations-in-a-set-in-a-single-request/3054/2 "2013-10-23T20:07:39Z")

</div>

I think this is the default behavior in the latest ember-data (1.0-beta3 as of writing), unless you specify `{async: true}` in your hasMany relationship. Your users payload might look something like this:

```nohighlight
{
  "users": [{...}, {...}],
  "memberships": [{...}, {...}]
}

```

---

<div class="post-metadata">

**Author:** ![lukegalea](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/lukegalea/32/4306_2.png) [@lukegalea](https://discuss.emberjs.com/u/lukegalea)\
**Post date:** [October 24, 2013, 1:37pm UTC](https://discuss.emberjs.com/t/loading-all-the-associations-in-a-set-in-a-single-request/3054/3 "2013-10-24T13:37:10Z")

</div>

Thanks daliwali. I’m trying to avoid loading both the users and memberships in a single query because not every place in the app wants them both.

If I include just the ids for memberships, and don’t mark the request as async I get:

You looked up the ‘memberships’ relationship on ‘…’ but some of the associated records were not loaded. Either make sure they are all loaded together with the parent record, or specify that the relationship is async (`DS.hasMany({ async: true })`)

Hence my need for something like:

```
this.get('users.@each.memberships').then(...) 

```
