You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lawrence Selvy edited this page Feb 27, 2014
·
1 revision
hasMany
Is a many to many relationship (includes join table).
Eg: Patient.hasMany('doctors', Doctor, { why: String }, { reverse: 'patients' }).
Patient can have many different doctors. Each doctor can have many different patients.
This will create a join table patient_doctors when you call Patient.sync():
column name
type
patient_id
Integer
doctor_id
Integer
why
varchar(255)
The following functions will be available:
patient.getDoctors(function..)// List of doctorspatient.addDoctors(docs,function...)// Adds entries to join tablepatient.setDoctors(docs,function...)// Removes existing entries in join table, adds new onespatient.hasDoctors(docs,function...)// Checks if patient is associated to specified doctorspatient.removeDoctors(docs,function...)// Removes specified doctors from join tabledoctor.getPatients(function..)etc...