【问题标题】:Issu normalizing data ( entity with children of same entity )发布规范化数据(具有同一实体的子实体的实体)
【发布时间】:2017-08-21 09:48:02
【问题描述】:

我对 normalizr 很陌生。

我正在尝试规范化如下所示的 json api 答案:http://myjson.com/15st3f

同一实体有一些嵌套元素。例如:

{
  "id": 1,
  "name": "a",
  [...]
  "children": [
    "id": 2,
    "name": "b",
    [...]
    "children": [
      "id": 3,
      "name": "c"
    ]
  ]
}

我应该如何开始?我有点困惑。可以正常化吗?你能有相同实体的数组,或者类似的东西吗?我可以做这样的事情吗? :

const uor = new schema.Entity('uors', {
    UorChildren: [ uor ]
})

【问题讨论】:

    标签: normalizr


    【解决方案1】:

    使用define instance method

    const uor = new schema.Entity('uors');
    uor.define({ children: [ uor ] });
    

    【讨论】:

    猜你喜欢
    • 2017-10-10
    • 1970-01-01
    • 1970-01-01
    • 2011-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-30
    • 2015-09-04
    相关资源
    最近更新 更多