You can use two different simple methods to get links to your account.
Using model definitions in the Model.json file.
"validations": [], "relations": { "team": { "type": "belongsTo", "model": "Team", "foreignKey": "" }, "user": { "type": "belongsTo", "model": "User", "foreignKey": "" } }
This always connects one model with other models using direct relationships, and you can get them using the following lines of code.
app.models.TeamRole.findOne({ where: { userId: user.id }, include:[ { relation: 'team' }, { relation: 'user' } ] },function(err,team,user){
- You can use operational hooks to easily get these kinds of relationships.
Greetings.
source share