relatedEntity is a relationship selector factory,
its call produces a relationship selector which can be used within root selectors and another suitable relationship selectors.
It is useful when the id of the related entity is stored in the parent entity.
entityStateSelector- is an entity state selector of a desired entity.
keyId- a property name in the parent entity which points to the id of the related entity,
User.companyId -> Company.id.
keyValue- a property name in the parent entity where the related entity should be assigned,
keyIdis an array of ids, then
keyValuehas to be an array of the related entities too.
relationships- is an optional parameter which accepts relationship selectors for the parent entity.
An example is the
User. Its model has
and there is
selectCompanyState that returns
Therefore, if we want a root selector which fetches a user with its company it might look like: