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
但是,这是行不通的。数据库只有一个关系表,其中必须为每个关系指定作者和编辑者,这甚至没有意义。
我该怎么做这样的事情?