How to make embedded hasMany relationships work with ember data

前端 未结 4 1615
既然无缘
既然无缘 2020-11-27 13:51

I can\'t get embedded hasMany to work correctly with ember data.

I have something like this

App.Post = DS.Model.extend({
          


        
4条回答
  •  -上瘾入骨i
    2020-11-27 14:45

    This is what worked for me (Ember 1.5.1+pre.5349ffcb, Ember Data 1.0.0-beta.7.f87cba88):

    App.Post = DS.Model.extend({
      comments: DS.hasMany('comment', { embedded: 'always' })
    });
    
    App.PostSerializer = DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {
      attrs: {
        comments: { embedded: 'always' }
      }
    });
    

提交回复
热议问题