Comments (7)
Resolved
from ngrx-entity-relationship.
Hi again,
might you explain how you tried to search for it? I'll try to add suitable keywords to improve search appearance.
There are several options:
- company should provide
staffId
.
export interface Company {
id: string;
name: string;
staffId?: Array<string>; // and array of ids to select
staff?: Array<User>;
admin?: User;
adminId?: string;
address?: Address;
addressId?: string;
}
const companyWithEmployees = rootEntity(
companySelector,
relatedEntity( // relatedEntity supports single ids and arrays of them.
userSelector,
'staffId',
'staff',
),
);
- user has
companyId
export interface User {
companyId?: string;
}
const companyWithEmployees = rootEntity(
companySelector,
childEntity( // childEntity searches for suitable users based on companyId == company.id.
userSelector,
'companyId',
'staff',
),
);
For many to many - might you provide your data structure and how you would like to select the records?
In my case I used typeorm
and for such relationships it returns data like staffId
.
from ngrx-entity-relationship.
I found you looking for the words "ngrx entity one to many":
https://stackoverflow.com/questions/61933118/ngrx-how-to-many-to-many-relationship-between-entities
I've been looking for weeks:
normalizing
https://redux.js.org/recipes/structuring-reducers/normalizing-state-shape
https://github.com/paularmstrong/normalizr
ngrx orm
https://gist.github.com/musou1500/6f7649bf230f1c7e06280b0103519b8b
from ngrx-entity-relationship.
Aha, thanks.
I'll try to promote "ngrx orm" and "ngrx normalizing". For the last weeks I've been working on redux version, because of that, I think, the next update will be ready only in 2-3 weeks.
Btw, does the thing about many-to-many work for you?
from ngrx-entity-relationship.
hi,
Hi, I tried the implementation, but I have an error.
companyId successfully finds it in the User entity
https://github.com/jucasoft/ngrx-entity-crud-prime-ng-boilerplate/blob/a8e3103ef42d063c832d04e190de45c9dc629f79/src/app/main/models/vo/user.ts#L8
staff, does not find it in Compani (even if present) it seems to look for it in User.
https://github.com/jucasoft/ngrx-entity-crud-prime-ng-boilerplate/blob/a8e3103ef42d063c832d04e190de45c9dc629f79/src/app/root-store/company-store/selectors.ts#L29
from ngrx-entity-relationship.
Yeah, my bad. Because it's an array not childEntity
, but childrenEntity
should be used.
const companyWithEmployees = rootEntity(
selectState,
childrenEntities(
UserStoreSelectors.selectState,
'companyId',
'staff',
),
);
from ngrx-entity-relationship.
another thing is that with the current approach it causes Warning: Circular dependency detected:
.
It's quite common because of cross relationships.
it's caused by
export const selectState: MemoizedSelector<object, State> = createFeatureSelector<State>(Names.NAME);
and
export const selectState: MemoizedSelector<object, State> = createFeatureSelector<State>(Names.NAME);
it should be in any other file, but not within ngrx-entity-relationship
selectors.
I put them in the state.ts
usually.
then it's like that: https://take.ms/nLoxh
I've created a PR: jucasoft/ngrx-entity-crud-prime-ng-boilerplate#1
from ngrx-entity-relationship.
Related Issues (20)
- Accept an id selector as a param of a relationship selector. HOT 1
- Select filtered relations HOT 5
- Add the transform feature to related selectors HOT 1
- ngrxEntityRelationshipReducer with @ngrx/data has unexpected behavior
- reduceGraph doesn't update collection in store HOT 3
- Handling missing entry in related entity state
- "real usage example" links don't work. HOT 2
- Looking to select a list of all entities from two entity caches using NgRx Data HOT 2
- Load entities with @ngrx/data requesting graphql server HOT 4
- [FEATURE] suggestions for gqlFelds HOT 4
- Action Required: Fix Renovate Configuration HOT 1
- Depreceted NGRX selectors with props HOT 5
- local cache from GraphQL based on object type as a root key
- NGRX-Entity-Relationship Graph do not receive the selector HOT 1
- populate ids automatically on graphql reduce
- Use root selector factories for rel factories
- gqlIgnore
- Dependency Dashboard
- how to configure ngrxEntityRelationshipReducer HOT 15
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngrx-entity-relationship.