如何在bookshelfjs中使用多个belongsTo?

How to use multiple belongsTo in bookshelfjs?

我有一个 Table,名称为“class”,它有两个外键 attendance_idsyllabus_id,但是使用 JOIN 我只能得到一个外键值,这是我的模型,

var AttendanceType = bookshelf.Model.extend({
   tableName: 'attendance_type',
});
var SyllabusName = bookshelf.Model.extend({
   tableName: 'syllabus_name',});
var Class = bookshelf.Model.extend({
   tableName: 'class',
AttendanceRef: function() {
   return this.belongsTo(AttendanceType);
},
SyllabusRef: function() {
   return this.belongsTo(SyllabusName);
}
});
module.exports = Class;

这是我的控制器,

.fetchAll({ withRelated: ['AttendanceRef','SyllabusRef']})

但我只从“attendance_type”Table.

获取数据
var AttendanceType = bookshelf.Model.extend({
   tableName: 'attendance_type',
});

var syllabusName = bookshelf.Model.extend({
   tableName: 'syllabus_name',
});

var Class = bookshelf.Model.extend({
   tableName: 'class',
   AttendanceRef: function() {
      return this.belongsTo(AttendanceType,'attendance_type_id');
   },
   SyllabusNameRef: function() {
      return this.belongsTo(syllabusName,'syllabus_id');
   }
});
module.exports = Class;

这是我的控制器。

.fetchAll({ withRelated: ['AttendanceRef','SyllabusNameRef']})