我有一个类似于以下模型的模型:
var ScholarlyPaper = Bookshelf.Model.extend({
tableName: 'papers',
paragraphs: function() {
return this.hasMany(Paragraph).through(Section);
},
sections: function() {
return this.hasMany(Section);
}
});
var Section = Bookshelf.Model.extend({
tableName: 'sections',
paragraphs: function() {
return this.hasMany(Paragraph);
}
scholarlyPaper: function() {
return this.belongsTo(ScholarlyPaper);
}
});
var Paragraph = Bookshelf.Model.extend({
tableName: 'paragraphs',
section: function() {
return this.belongsTo(Section);
},
scholarlyPaper: function() {
return this.belongsTo(ScholarlyPaper).through(Section);
},
author: function() {
return this.belongsTo(Author);
}
});
var Author = Bookshelf.Model.extend({
tableName: 'authors',
paragraphs: function() {
return this.hasMany(Paragraph);
}
});
使用Bookshelf.js,给定一篇学术论文的id和作者的id,如何获取作者没有写过任何段落的论文中的所有章节?
我面临的特定挑战是,据我所知,没有办法在相关表上添加where子句(例如'where paragraphs.author_id!= author_id')。