当我想定义一个组织有很多组织时,models.json应该是什么样的?
我尝试通过relationshio定义一个hasMany,使用一个名为clients的中间模型,但它没有工作:
"organization": {
"properties": {
"name": {
"type": "string"
}
},
"relations": {
"clients": {
"type": "hasMany",
"model": "organization",
"foreignKey": "clientId",
"through": "client"
}
}
"client": {
"properties": {
"organizationId": {
"type": "number",
"id": true
},
"clientId": {
"type": "number",
"id": true
}
},
"relations": {
"organization": {
"type": "belongsTo",
"model": "organization",
"foreignKey": "organizationId"
},
"client": {
"type": "belongsTo",
"model": "organization",
"foreignKey": "clientId"
}
}
}