Resolving references #119
Unanswered
PhilipHenworx
asked this question in
Q&A
Replies: 1 comment
-
You need to create a query that builds it based on the ids: store
.combine({
movies: store.pipe(selectAll()),
geners: store.pipe(selectEntities({ ref: GenresEntitiesRef })),
actors: store.pipe(selectEntities({ ref: ActorsEntitiesRef })),
})
.pipe(map(data => {
return data.movies.map(movie => {
return {
...movie,
genres: movie.genres.map(id => data.genres[id]),
actors: movie.actors.map(id => data.actors[id])
}
})
})); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using the movies example from here: https://ngneat.github.io/elf/docs/features/entities/ui-entities
After all is set up, it adds the "Gone in 60 Seconds" entity to the movies, with
genres: ['1']
and actors: ['1'].Is there a way to resolve the reference when retrieving the movie entity? console.log-ing the state says it is exactly, what is written: genres and actors are just string arrays.
I could re-define the interface / class of Movie so genres and actors are Genre[] and Actor[], but when I update... let's say the "Nicolas Cage" entity name to "Nic Cage", the changes won't reflect in the movie.
Beta Was this translation helpful? Give feedback.
All reactions