I'm having trouble getting LoopBack to perform a many-to-many join query. Considering the hasManyThrough example from the documentation:
var Physician = ds.createModel('Physician', {name: String});
var Patient = ds.createModel('Patient', {name: String});
var Appointment = ds.createModel('Appointment', {
physicianId: Number,
patientId: Number,
appointmentDate: Date
});
Appointment.belongsTo(Patient);
Appointment.belongsTo(Physician);
Physician.hasMany(Patient, {through: Appointment});
Patient.hasMany(Physician, {through: Appointment});
If I try to do a single search to find Patients associated with a particular doctor who have a zip code of 10012, I could try:
physician.patients({where: {zip: 10012}}, fn);
However, the search on the physician's patients is actually only searching on the Appointments table. Is there any way to do a simple search that will be performed on the specific physician's patients directly?