Ember-Data recursive hasMany association

前端 未结 3 969
小鲜肉
小鲜肉 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

    This didn't work for me until I set up the inverse:

    App.Node = DS.Model.extend({
        children: DS.hasMany('App.Node', {inverse: 'parent'}),
        parent:   DS.belongsTo('App.Node', {inverse: 'children'}) });
    

提交回复
热议问题