# FixtureAdapter and DS.hasMany

**URL:** <https://discuss.emberjs.com/t/fixtureadapter-and-ds-hasmany/3495>\
**Category:** Ember Data\
**Created:** [December 4, 2013, 5:59am UTC](https://discuss.emberjs.com/t/fixtureadapter-and-ds-hasmany/3495 "2013-12-04T05:59:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mpl](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/mpl/32/15216_2.png) [@mpl](https://discuss.emberjs.com/u/mpl)\
**Post date:** [December 4, 2013, 5:59am UTC](https://discuss.emberjs.com/t/fixtureadapter-and-ds-hasmany/3495/1 "2013-12-04T05:59:51Z")

</div>

Hey - I’ve been building out a sample application with Ember over the past few days and am running into a fairly large issue with the `FixtureAdapter` and a `hasMany` relationship.

I’m building a simple time tracking utility and want to be able to access multiple `TimeEntry` records via a `Task`.

There’s no trouble loading the `Task` through it’s `belongsTo` relationship from `TimeEntry`, but going vice versa and getting the `manyArray` of `TimeEntry` objects doesn’t work.

Here’s the most simple implementation of the models. I’m just wondering if anyone has experience with getting this to work… Am I making some dumb mistake, or does this just plain not work?

```auto
App.Task = DS.Model.extend({
  name: DS.attr(),
  timeEntries: DS.hasMany('time_entry'),
});

App.Task.FIXTURES = [
  {
    id: 1,
    name: 'Tracking time.',
    time_entries: [1,2]
  }
];

App.TimeEntry = DS.Model.extend({
  startTime: DS.attr('date'),
  endTime: DS.attr('date'),
  task: DS.belongsTo('task')
});

App.TimeEntry.FIXTURES = [
  {
    id: 1,
    startTime: "2013-11-29T04:52:17.249Z",
    endTime: "2013-11-29T06:52:17.249Z",
    task: 1
  }, {
    id: 2,
    startTime: "2013-11-22T06:52:17.249Z",
    endTime: "2013-11-21T06:52:17.249Z",
    task: 1
  }
];

```

Any help would be SO appreciated.

Thanks!

---

<div class="post-metadata">

**Author:** ![tarasm](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/tarasm/32/15980_2.png) [@tarasm](https://discuss.emberjs.com/u/tarasm)\
**Post date:** [December 4, 2013, 9:58am UTC](https://discuss.emberjs.com/t/fixtureadapter-and-ds-hasmany/3495/2 "2013-12-04T09:58:30Z")

</div>

I don’t have experience with this personally, but from what I know FixtureAdapter is very limited in its abilities. Look through issues in [Ember Data that include hasMany keyword](https://github.com/emberjs/data/search?q=fixtureadapter%20hasMany&type=Issues) ( if you haven’t already done so ).

---

<div class="post-metadata">

**Author:** ![mpl](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/mpl/32/15216_2.png) [@mpl](https://discuss.emberjs.com/u/mpl)\
**Post date:** [December 5, 2013, 9:56am UTC](https://discuss.emberjs.com/t/fixtureadapter-and-ds-hasmany/3495/3 "2013-12-05T09:56:50Z")

</div>

Yeah - I guess I was hoping for a miracle with the 1.0.0-beta reboot.

It works pretty well with RESTAdapter, but this is another story.

Thanks!

---

<div class="post-metadata">

**Author:** ![lukewendling](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/lukewendling/32/15347_2.png) [@lukewendling](https://discuss.emberjs.com/u/lukewendling)\
**Post date:** [December 7, 2013, 4:42pm UTC](https://discuss.emberjs.com/t/fixtureadapter-and-ds-hasmany/3495/4 "2013-12-07T16:42:32Z")

</div>

I was having the same problem.

Try `time_entries: DS.hasMany('time_entry', {async: true})`

I stumbled on the async option somewhere along the way.

---

<div class="post-metadata">

**Author:** ![joemail24](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/joemail24/32/15340_2.png) [@joemail24](https://discuss.emberjs.com/u/joemail24)\
**Post date:** [December 8, 2013, 9:11pm UTC](https://discuss.emberjs.com/t/fixtureadapter-and-ds-hasmany/3495/5 "2013-12-08T21:11:05Z")

</div>

I can vouch to seeing the same behavior. When I add a hasMany relationship, I get an error as follows (if I try to access the children from the parent):

> Assertion failed: You looked up the ‘items’ relationship on ‘\<(subclass of DS.Model):ember291:1\>’ 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 })`)

and adding `{async: true}` only gets rid of the error. The child items still aren’t accessible.

note: I’m using ember-app-kit and doing `reopenClass` on the the models to define the `FIXTURES`

```
var Group = DS.Model.extend({
  items: DS.hasMany('item')
}); 

Group.reopenClass({
  FIXTURES: [{ ... }]
});

```
