Closed getsnoopy closed 3 years ago
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS
file at the top-level of this repository.
Steps to reproduce
toJSON
on the main model instance.Here are examples:
Current Behaviour
The output of
toJSON
does not include data from the related model instance.Expected Behaviour
The output of
toJSON
should include the related model's result, since it seems like the retrieval from step 2 is being cached in the main model instance via the__cachedRelations
property.Additional information
This seems to happen because the
toJSON
method only returns properties which are a part of the__data
property. When using aninclude
filter via a retrieval method (e.g.,findById
), the included relations are promoted to direct properties, whereas the same does not happen when retrieving the relations via relation functions (e.g., via aBelongsTo
relation).Node version information:
Loopback version information:
Link to reproduction sandbox
https://github.com/getsnoopy/loopback-sandbox