I have an entity with nested relations, and I want to select a certain field from the nested relation. This is my query:
const data = await this.entityRepository.find({
select: {
id: true,
code: true,
description: true,
groupDetails: {
primaryGroup: {
id: true,
},
},
},
relations: {
groupDetails: {
primaryGroup: true,
secondaryGroup: true,
},
}
});
I’ve expected to get groupDetails.primaryGroup.id
in the res objects, but the field groupDetails
doesn’t appear in any of them.
If I remove it from the select like this:
const data = await this.entityRepository.find({
select: {
id: true,
code: true,
description: true,
},
relations: {
groupDetails: {
primaryGroup: true,
secondaryGroup: true,
},
}
});
I do get groupDetails
in the res objects.
How can I achieve the functionality i’m looking for?