when relation of two models is defined as 'hasManyThrough', how to update 'through' model instance created as linking instances of two models?
For example, it assumes that models are defined like the followings.
common/models/physician.json
{
"name": "Physician",
"base": "PersistedModel",
"properties": {
"name": {
"type": "string"
}
},
"validations": [],
"relations": {
"patients": {
"type": "hasMany",
"model": "Patient",
"foreignKey": "patientId",
"through": "Appointment"
},
common/models/patient.json
{
"name": "Patient",
"base": "PersistedModel",
"properties": {
"name": {
"type": "string"
}
},
"validations": [],
"relations": {
"physicans": {
"type": "hasMany",
"model": "Physician",
"foreignKey": "physicianId",
"through": "Appointment"
},
common/models/appointment.json
{
"name": "Appointment",
"base": "PersistedModel",
"properties": {
"appointmentDate": {
"type": "date"
}
},
"validations": [],
"relations": {
"physician": {
"type": "belongsTo",
"model": "Physician",
"foreignKey": "physicianId"
},
"patient": {
"type": "belongsTo",
"model": "Patient",
"foreignKey": "patientId"
},
In API explorer, only four API for handling Appointment are exposed.
- PUT /physicians/{id}/patients/rel/{fk}
- DELETE /physicians/{id}/patients/rel/{fk}
- PUT /patients/{id}/physicians/rel/{fk}
- DELETE /patients/{id}/physicians/rel/{fk}
As I now, PUT method is just for creating new AppointMent instance and DELETE method is just for removing it.
What is REST API for updating already created Appointment instance?
May I just use PUT /appointment/{id} for updating it?