如何规范分页数据?

时间:2018-08-30 13:44:52

标签: reactjs redux normalizr

我需要这样转换数据:

{peopleList: [{id:1, name: 'joe'}, {id: 2, name: 'john'}], page: 1, rowPerPage: 8}

此模型:

{entities: {'0': {id: 0, name: 'joe'}, '1': {id: 1, name: 'john'}, page: 1, rowPerPage: 8}, result: [0, 1]}

但是当我添加此架构时:

const people = new schema.Entity('peopleList');
const normalizedData = normalize(_data, { peopleList: [people] });

我得到以下输出:

{
      "entities": {
        "peopleList": {
          "1": {
            "id": 1,
            "name": "joe"
          },
          "2": {
            "id": 2,
            "name": "john"
          }
        }
      },
      "result": {
        "peopleList": [
          1,
          2
        ],
        "page": 1,
        "rowPerPage": 8
      }
    }

我不完全知道如何制作合适的架构来创建结果,这是我的愿望。也许正确的方法是得到结果,并且此输出正确。有什么主意吗?

0 个答案:

没有答案