当我想定义一个组织有很多组织时,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"
}
}
}