You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using "lb4 relation" I've confirmed that all inclusion resolvers for these relationships are in place and working. The relevant portion of my backend function is below:
When I test it within explorer I am able to get the associated devicetempl's associated with this user, but it does not contain the devices associated with the devicetempl.
Looking into the mongodb debug log, I can see the result of the query does contain the devices associated with the devicetempl, but for some reason they are not contained in the explorer output.
Is there a possible bug between Loopback 4 and MongoDB nested HasMany queries or does anyone else possibly spot anything else wrong with what I am doing?
Steps to reproduce
There are 3 controllers
Models have the following relations
User.model.ts
@hasmany(() => Device)
devices: Device[];
@hasmany(() => Devicetempl)
devicetempls: Devicetempl[];
Devicetempl.model.ts
@hasmany(() => Device)
devices: Device[];
@belongsTo(() => User)
userId: string;
device.model.ts
@belongsTo(() => Devicetempl)
devicetemplId: string;
using "lb4 relation" I've confirmed that all inclusion resolvers for these relationships are in place and working. The relevant portion of my backend function is below:
async find(@param.path.string('id') id: string>): Promise<(User & UserRelations)[]> { let foundUser = await this.userRepository.find({ include: [ { relation: 'devicetempls', scope: { include: [{relation: 'devices'}], }, }, ], where: {id: id}, }); return foundUser; }
When I test it within explorer I am able to get the associated devicetempl's associated with this user, but it does not contain the devices associated with the devicetempl.
Looking into the mongodb debug log, I can see the result of the query does contain the devices associated with the devicetempl, but for some reason they are not contained in the explorer output.
loopback:connector:mongodb all Device { fields: [ 'deviceid' ], where: {} } null [ { _id: 5f3c7d49d1b72df053895ee6, deviceid: '1234567' }, { _id: 5f3d6551c3f1126e385867db, deviceid: 'abcdef' } ]
I've confirmed that my formatting looks correct using issues #3453 and #4644, as well as reading the bottom section of these master docs:
https://github.com/strongloop/loopback-next/blob/master/docs/site/HasMany-relation.md#query-multiple-relations
.Additionally, a previous StackOverflow question (48391685) seems to address this formatting and everything looks to match.
Is there a possible bug between Loopback 4 and MongoDB nested HasMany queries or does anyone else possibly spot anything else wrong with what I am doing?
Thank you in advance for the help!
Additional information
npm ls --prod --depth 0 | grep loopback
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── [email protected]
The text was updated successfully, but these errors were encountered: