Loopback-next: includes with belongTo and hasMany relations

Created on 10 Sep 2020  路  4Comments  路  Source: strongloop/loopback-next

I have this filter

{"where":
{"and": [
{"idCliente": "${cliente}"},
... // more filters
]
}
,
"include": [
{
"relation": "Articulos", <---hasMany
"relation": "vendedor" <---belongto
}
],"order":["fecha DESC"]
}

but the response only get belongTo relations but omit hasMany relation
if i include only one in filter, not both, working fine

Relations bug

All 4 comments

@fgvicente please share a minimal app reproducing the behavior, we can take a look at the issue.

If you want to query more than one relation, you have to use the following syntax:

"include": [{"relation": "Articulos"}, {"relation": "vendedor"}]

the schema with relation is like this
'{
"include":[
{
"relation":"insured",
"scope":{
"where":{
"insured_city":"Carora"
}
}
}
]
}'

@nabdelgadir thanks!! now works

Was this page helpful?
0 / 5 - 0 ratings