【发布时间】:2018-01-06 02:09:57
【问题描述】:
使用 normalizr 库后,我的应用程序的 Redux 状态中有以下标准化 JSON 对象结果:
{
sports: {
byId: {
1: {
id: 1,
name: 'Soccer',
slug: 'soccer'
},
2: {
id: 2,
name: 'Basketball',
slug: 'basketball'
},
3: {
id: 3,
name: 'American Football',
slug: 'american-football'
}
},
allIds: [
'1',
'2',
'3'
]
},
competitions: {
byId: {
'1': {
id: 1,
name: 'Competition 1',
short_name: 'Comp 1',
slug: 'comp-1',
sport: 1,
status: {
is_live: false
}
},
'2': {
id: 2,
name: 'Competition 2',
short_name: 'Comp 2',
slug: 'comp-2',
sport: 1,
status: {
is_live: true
}
},
'3': {
id: 3,
name: 'National Basketball League',
short_name: 'NBA',
slug: 'national-basketball-league',
sport_slug: 'basketball',
sport: 3,
status: {
is_live: true
}
}
},
allIds: [
'1',
'2',
'3'
]
}
我想要实现的目标:我想要一个由sports 过滤/分类的competitions 列表。
我该怎么做?
我还希望能够将competitions 分组为status.is_live。
那么我怎样才能得到sport 的competitions 细分列表,status.is_live 等于 true,competitions status.is_live 等于 false?
任何帮助表示赞赏!谢谢
【问题讨论】:
标签: javascript json redux normalizr