I am new to Loop Back, but I want to use it for my upcoming API application. I am currently testing the features it has to offer, but I'm stuck on doing an advance query on a sub model of my root entity. I apologize in advance if this is already answered, but I've spent hours searching the web for answers and have not gotten anywhere. Furthermore, I saw below on LB4 website, but for unknown reasons it's not working for me.
customerRepo.find({
include: [
{
relation: 'orders',
scope: {
where: {name: 'ToysRUs'},
include: [{relation: 'manufacturers'}],
},
},
],
});
I am essentially using two models - User and Note where User has many Notes. I used LB4 CLI 99.9% of times to create the datasource, models, repositories and relations. I have even added inclusion resolver to my note repository as below.
this.registerInclusionResolver('user', this.user.inclusionResolver);
However, when I try to run below filter against my note repository, it does not apply the where
filter against User. Oddly, when I add the scope
block, the user is no longer included in the response.
{
"limit": 5,
"include": [
{
"relation": "user",
"scope": {
"where": {
"username": "jdoe@example.com"
}
}
}
]
}
My project is a boilerplate code created using lb4 app
command. I've then added my datasource, models, repositories, and controllers.
Any help will be greatly appreciated.