-
-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Select filtered relations #1445
Comments
Hi there, you can either pass desired selector (which filters items) to |
Hi, |
Here you go, an example how to create a selector just for active users. https://codesandbox.io/s/happy-bas-dhu0fp?file=/src/app/store/reducers.ts line 84+ |
thanks, it's super useful!
|
ah, I think, everything is much simpler here, you can use a pipe operator: https://ngrx-entity-relationship.sudo.eu/api/rxjs/relationships this.store.pipe(
switchMap(state => {
return this.store
.select(selectProductsByCollection(this.collectionKey)) // <- should be a normal selector of products only
.pipe(relationships(store, selectProductById)); // <- should be a ngrx-entity-relationships selector to fill related entities
})
).subscribe(k => console.log(k)) |
Here is my case. I have two stores:
orders
andarticles
. Order is connected with articles with one to many relation.artciles
containorderId
which is the relational key .Here is the structure of both objects:
So, what I have into the selectors:
First I need to fetch all articleIds which have a specific status
then lets try to create a selector which will return only desired articles:
If I create a store selector from the last:
and subscribe to that, as result will have only the filtered articles. This is great, but now I want to select orders, with their ONLY FILTERED articles! How I can do that?
What I've trying is following:
I expected
selectOrderWithArticles
to return orders with the filtered articles because I've usedselectAllOrderedArticles
, but actually I receive all articles instead.Do I have something wrong, or there is a bug in the package?
The text was updated successfully, but these errors were encountered: