-
Notifications
You must be signed in to change notification settings - Fork 1
FetchingRelationships
Mihael Šafarić edited this page Sep 2, 2019
·
4 revisions
When fetching a model via findOne
method, or when fetching a list of models via find
method, includeRelationships
parameter can be passed.
includeRelationships
is an array of strings which represents the model relationship names or the relationship names of nested models.
Valid includeRelationships
values:
All the examples below assume fetching a user with specified relationships.
-
[]
- fetches a user without any additional calls
-
['address']
- fetches a user and when the user is fetched, it extracts
address
relationship URL from the response and fetchesaddress
resource
- fetches a user and when the user is fetched, it extracts
-
['address.city']
- fetches a user and when the user is fetched, it extracts
address
relationship URL from the response and fetchesaddress
resource - after the address is fetched, it extracts
city
relationship URL from the response and fetchescity
resource
- fetches a user and when the user is fetched, it extracts
-
['address', 'address.city']
- the same behaviour as
['address.city']
- the library figures out that
address
will already be fetched as a part ofaddress.city
,so it skips that additional request
- the same behaviour as