我想實現一個有很多通過關係闡述here。但是,我的相關模型與通過自連接的引用模型相同。我嘗試這樣做:有很多通過自我加入batmanjs
class Article extends Batman.Model
@hasMany 'citations'
@hasMany 'usages', name: 'Citation', foreignKey: 'referenced_article_id'
@accessor 'referenced_articles', ->
@get('citations').mappedTo('referenced_article')
class Citation extends Batman.Model
@belongsTo 'article'
@belongsTo 'referenced_article', name: 'Article'
不幸的是,呼籲my_article.get('referenced_articles')
給出了一個錯誤。有任何想法嗎?
您可以從網站(http://batmanjs.org/download.html)下載蝙蝠俠/主人,但它有一些其他突破性更改(請參閱https://github.com/batmanjs/batman/issues/1106) 。 在捏,你可以在你的應用定義之前添加那行^^。我在修復它之前先修好它。 – rmosolgo 2014-08-28 14:27:23