How can I properly normalize big data using normalizr? I get an nested data from the api and I need to divide it by the user entities, where the data will be stored separately.
data from api
[
{
user: {
email: "[email protected]"
lastname: "User"
name: "User"
password: "123"
_id: 1,
}
date: "2021",
details: [
{
category: "admin"
name: "superadmin"
access: 1
}
],
_id: 'xdre24d'
}
]
schema
const userSchema = new schema.Entity('userSchema', {}, { idAttribute: '_id' });
const users = new schema.Entity(
'users',
{ user: new schema.Array(userSchema) },
{ idAttribute: '_id' },
);
const normalData = normalize(data, new schema.Array(users));
how would you like to get normalizr data
entities: {
user: {
a: {
name: "User"
email: "[email protected]",
lastname: "User"
},
b: {
name: "User"
email: "[email protected]",
lastname: "User"
}
}
}