I'm currently working on a project where ngrx-data is used to store the information. So far it works great, but now I want to store the entity data from an endpoint which gives me two separate entity types in its response.
{
"posts": [
{
"id": 1,
"title": "Title"
},
{
"id": 2,
"title": "Title 2"
}
],
"users": [
{
"id": 1,
"username": "Username"
},
{
"id": 2,
"username": "Username 2"
}
],
"date": "1996-10-15T00:05:32.000Z"
}
Now I want to save them separately in the entityCache
of ngrx-data. For this I have implemented the basic HTTP service in Angular which extends the DefaultDataService
. This I integrated into my facade and added the necessary metadata.
constructor(entityServices: EntityServices) {
this.postsAndUsersService = entityServices.getEntityCollectionService(
'PostsAndUsers'
);
}
export const entityMetadata: EntityMetadataMap = {
PostsAndUsers: {
selectId: selectIdPostsAndUsers
}
}
I'm able to get all the received information "as a whole" from the store, but I think I'm loosing many advantages I get from using ngrx-data (like getting an array of ids).
Is there some way to normalize/split the data and writing it into different sections of the entityCache
?
Thank you very much for any hint.