文章有很多作者,编辑,翻译等。所有类人。 是否可以生成连接模型?或者,在这种情况下,解决方案是手动创建每个连接模型。
class Article
include DataMapper::Resource
property :id, Serial
property :published_date, Date
property :status, Enum[ :pending, :accepted, :declined, :modified, :new ], :default => :new
property :visible, Boolean, :default => false
timestamps :at
has n, :authors, 'Person', :through => Resource
end
class Person
include DataMapper::Resource
property :id, Serial
property :name, String
property :about, Text
property :gender, Enum[ :male, :female ]
property :birthday, Date
timestamps :at
has n, :articles, :through => Resource
end
答案 0 :(得分:0)
看起来不可能。仅手动创建模型。