2017-08-29 93 views
0

讓我有這種情況迴環:嵌套關係,讓家長在查詢

型號: - 競爭 - 競爭賽季 - 比賽

在競爭季節有:

"relations": { 
    "matches": { 
     "type": "hasMany", 
     "model": "match", 
     "foreignKey": "competition-seasonId" 
    }, 
    "competition": { 
     "type": "belongsTo", 
     "model": "competition", 
     "foreignKey": "" 
    } 
    } 

並且匹配有:

"relations": { 
    "competition-season": { 
     "type": "belongsTo", 
     "model": "competition-season", 
     "foreignKey": "" 
    } 
} 

我所試圖做的是列出的比賽時,爲了獲得競爭對象,但與此

{ 
    include: ['competition-season'] 
} 

現在我想起來了

[ 
    { 
    id: 'xxxx', 
    competition-seasonId: 'yyyy', 
    competition-season: { 
     competitionId: 'zzzz' 
    } 
    } 
] 

所以想獲得的競爭對象,不只是身份證

回答

0

我自己找到了!

include: [ 
    { 
    relation: 'competition-season', 
    scope: { 
     include: 'competition' 
    } 
    } 
] 

例如這裏:enter link description here

現在應該愛迴環