如何从子模型获取父表的属性

var ParentModel = bookshelf.Model.extend({ }); var ChildModel = ParentModel.extend({ }); new ChildModel().fetch().then(function(child){ console.log(child.get('parentAttribute')); //undefined }); 

我怎样才能从子对象获得inheritance的表属性?

遗憾的是,Bookshelf不支持inheritance关系。 在我在书架论坛的post中,我被build议使用名为Virtuals的插件来通过向子模型添加getter和setter来模拟这种行为。

https://github.com/tgriesser/bookshelf/issues/612