给定一个如下所示的输入:
[
{
id: 11,
valueId: 22,
valueDescription: 'Some value',
referenceId: 33,
referenceDescription: 'Some reference',
groupId: 44,
groupDescription: 'Some group'
},
{
id: 55,
valueId: 66,
valueDescription: 'Another value',
referenceId: 77,
referenceDescription: 'Another reference',
groupId: 88,
groupDescription: 'Another group'
}
]
以及所需的输出:
{
entities: {
types: {
"11": { id: 11, valueId: 22, referenceId: 33, groupId: 44 },
"55": { id: 55, valueId: 66, referenceId: 77, groupId: 88 },
},
values: {
"22": { id: 22, description: "Some value" },
"66": { id: 66, description: "Another value" },
},
references: {
"33": { id: 33, description: "Some reference" },
"77": { id: 77, description: "Another reference" },
},
groups: {
"44": { id: 44, description: "Some group" },
"88": { id: 88, description: "Another group" },
}
},
result: [ 11, 55 ]
}
我不确定如何为我的 4 种实体类型定义模式,这些实体类型会将多个字段从展平的根对象中拉出并重命名它们。我看到有一个assignEntity
我可以传递的论点,我认为我会使用它来重命名部分,但我不确定如何定义 aSchema
来表示一个平面对象变成四个实体。