0
我想在Bookshelf.js中創建一個多對多關係,並且想自己指定FK-columns的名稱。我也希望能夠訪問Bookshelf中的幫助表,以及類似於此:如何在Bookshelf.js中使用自定義字段名稱創建多對多關係?
var Doctor = bookshelf.Model.extend({
patients: function() {
return this.belongsToMany(Patient).through(Appointment);
}
});
var Appointment = bookshelf.Model.extend({
patient: function() {
return this.belongsTo(Patient);
},
doctor: function() {
return this.belongsTo(Doctor);
}
});
var Patient = bookshelf.Model.extend({
doctors: function() {
return this.belongsToMany(Doctor).through(Appointment);
}
});
我該怎麼做?