I have forked the loopback-example-relations repository for my example.
In the original repository we have a 'customer' model which embeds many 'email-addresses'.
I added a new relation to the email-address model which belongsTo an account.
email-address.json
"relations": {
"account": {
"type": "belongsTo",
"model": "Account",
"foreignKey": "accountId"
}},
I know the example doesn't make much sense, I just wanted to use existing models in my example
so:
customer --> emails --> account
When I call the following API endpoint
with the following filter
I get the result (account information is included)
[
{
"label": "home",
"address": "la...@yahoo.com",
"id": "252269b9a4f55b8c6c725b2a",
"accountId": "57fd44bbb9e3c793d68293d8",
"name": "home",
"account": {
"name": "Checking",
"balance": 5000,
"id": "57fd44bbb9e3c793d68293d8"
}
}
]
However, when I call the following endpoints
with the following filter:
I get the following result (account information is not included)
{
"name": "Larry Smith",
"id": "57fe689783b9acc04ea083d3",
"emailList": [
{
"label": "home",
"address": "la...@yahoo.com",
"id": "252269b9a4f55b8c6c725b2a",
"accountId": "57fd44bbb9e3c793d68293d8",
"name": "home"
}
],
"accountIds": [],
"emails": [
{
"label": "home",
"address": "la...@yahoo.com",
"id": "252269b9a4f55b8c6c725b2a",
"accountId": "57fd44bbb9e3c793d68293d8",
"name": "home"
}
]
}
Question: can the include filter "populate" sub-relations? When calling customer, I would like to see the emails and the account within each email, but this is not currently the case. Is this a bug that should be reported or by design?