get the child's child attributes its parent
Hi,
The below function is working, getting all the details of the users and its association. Can we get the child's child attributes in the children? Is there any way I can fetch the count of starsST in each story and "behaviourName" attribute in the story model.
I already tried sequelize hierarchy. I am looking forward to your suggestion. Thanks
const teamMemberDetails = await this.userModel.findAll({ hierarchy: true, attributes: ['id','firstName','lastName', 'fullName' , 'dateOfBirth', [Sequelize.col("Office.officeName"), "Location"], 'phoneNumber',
],
include:[
{
model:this.officeModel, as:'Office',
attributes: ['officeName']
},
{
model:this.storiesModel, as: 'storiesTM',
hierarchy: true,
attributes: ['creationOn',
Sequelize.col('child.lastName')), 'StoryFor'],
],
include:[{
model:this.behavioursModel, as: 'behaviour',
hierarchy: true,
attributes: ['behaviourName'],
},{
model:this.userModel, as :'child',
attributes: ['firstName','lastName','fullName',],
},
{
model:this.starStoriesModel, as :'starsST',
attributes: ['id'],
}
]
},
{
model:this.teamsModel, as: 'teamMembers',
attributes: ['childId'],
include:[{
model:this.userModel, as :'child',
attributes: ['firstName', 'lastName','fullName','startDate'],
}]
}
],
where :{id:userId},
})
return teamMemberDetails;
can i see your model class and your database settings ?? I need this hierarchy too.
Closing this due to inactivity