1
如何使用DataMapper在相同模型之間設置has n, :through => Resource
類型的多個關係?DataMapper:多個在同一模型之間具有 - 屬於多個關係?
例如,在一個新聞CMS我想有這樣的事情:
class User
include DataMapper::Resource
has n, :written_articles, 'Article', :through => Resource
has n, :edited_articles, 'Article', :through => Resource
property :name, String # etc.
end
class Article
include DataMapper::Resource
has n, :authors, 'User', :through => Resource
has n, :editors, 'User', :through => Resource
property :title, String # etc.
end
但是,這是行不通的。數據庫只有一個關係表,其中必須爲每個關係指定作者和編輯者,這甚至沒有意義。
我該怎麼做這樣的事情?