1
엔티티를 건너 뛰려고합니다. 나는 을 idAttribute
에서 돌려 주려고했으나 건너 뛰지는 않습니다. 이것이 가능한가? 내가 키 id
이 없을하지 않는 항목을 건너 뛸 그러나특정 속성을 기반으로 엔티티 건너 뛰기
articles: {
1: {commenter: "foo", id: 1}
2: {commenter: "bar", id: 2}
undefined: {dummy: true}
}
:
var { schema, normalize } = require("normalizr")
// Define your article
const article = new schema.Entity('articles', undefined, {
idAttribute: value => value.id
});
const reply = {
articles: [ { id:1, commenter:'foo' }, { id:2, commenter:'bar' }, { dummy:true } ]
}
const normalizedData = normalize(reply, { articles: [ article ] });
console.log('normalizedData.entities:', JSON.stringify(normalizedData.entities));
이 우리에게 normalizedData.entities
의 데이터를 제공합니다. 이것은 실제 사례의 매우 단순화 된 사례입니다.