is there any way to query related model's related model like from post
\Get:
{"order": "created_at DESC","include":[{"relation": "user"}]
But, in my user
model there is a relation hasone
with settings
model. I want to get that also, while querying from post
\Get rest api. I've tried with:
{ "include": { "relation": "user","include": {"relation":"settings"}}}
but no luck.
I've create nested relationship to related to your question.
example : teamRole.json
TeamRole > belongTo > User and Team
"validations": [],
"relations": {
"team": {
"type": "belongsTo",
"model": "Team",
"foreignKey": ""
},
"user": {
"type": "belongsTo",
"model": "User",
"foreignKey": ""
}
}
Retrieve results
app.models.TeamRole.findOne({
where: {
userId: user.id
},
include:[ {
relation: 'team'
},
{
relation: 'user'
} ]
},function(err,team,user){
//retrieve relational data here
});
Try this approach, hope this will helpful.