我有两个模型users
和appointments
.
users
模型如下-
{
"users": {
"0": {
"id": "1",
"name": "test1",
"role": "doctor"
},
"1": {
"id": "2",
"name": "test2",
"role": "patient"
},
"2": {
"id": "3",
"name": "test3",
"role": "support"
}
}
}
现在在上面的模型中,如果角色是医生,我们称它为doctor_id
,如果patient
那么patient_id
等等。
现在我的约会模式如下->
{
"name": "appointments",
"plural": "appointments",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"appointmentDate": {
"type": "date"
},
"appointmentTime": {
"type": "string"
},
"doctorId": {
"type": "string"
},
"patientId": {
"type": "string"
}
},
"validations": [],
"relations": {
"Doctor": {
"type": "belongsTo",
"model": "users",
"foreignKey": "doctorId"
},
"Patient": {
"type": "belongsTo",
"model": "users",
"foreignKey": "patientId"
}
},
"acls": [],
"methods": {}
}
所以当我尝试GET
所有约会时,它不会发送关系数据users
。如果我添加单个关系,它会按预期工作,但不能处理来自同一模型的多个关系。
提前致谢,