Ember-Data recursive hasMany association

前端 未结 3 964
小鲜肉
小鲜肉 2021-01-31 12:03

Has anyone used ember-data to model a tree of data?

I would assume it would be something like:

Node = DS.Model.extend({
    children: DS.hasMany(Node),
          


        
3条回答
  •  清酒与你
    2021-01-31 12:58

    Not sure but as per example given in ember guide

    App.Post = DS.Model.extend({
      comments: DS.hasMany('App.Comment')
    });
    

    The JSON should encode the relationship as an array of IDs:

    {
      "post": {
        "comment_ids": [1, 2, 3]
      }
    }
    

提交回复
热议问题