0

I'm trying to create a sort of hierarchical structure where a parent model has children of the same model class, but it doesn't seem to work. When I do it, the children properties ends up with the max items in it. Probably not explaining this well, but checkout this JSBin to see what I mean.

Is this sort of thing possible with Ember Data? Any ideas how to get it to work?

Thanks!!

NicholasJohn16
  • 2,390
  • 2
  • 21
  • 45

1 Answers1

1

The problem is that you're not specifying an inverse to the relationship and Ember-Data is getting confused. (If you don't know what an inverse is, look here.) Luckily, it's a pretty simple fix. You can either declare a parent relationship, or just declare the inverse as null. If you change your relationship declaration to look like this, your JSBin works fine.

children: DS.hasMany('item', { inverse: null })
Community
  • 1
  • 1
GJK
  • 37,023
  • 8
  • 55
  • 74
  • Thanks. I tried setting a parent as the inverse, but was still having issues with that. Didn't know you could set the inverse to null and it work. – NicholasJohn16 Mar 20 '15 at 20:43