开发者

Datamapper Many-To-Many relation

Article has many authors, editors, translaters, etc. All of class Person. Is it possible to generate join model? Or, in this case, solution is to create each join models manually.

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 ]
  propert开发者_StackOverflow社区y :birthday, Date

  timestamps :at

  has n, :articles, :through => Resource
end


looks like it impossible. Only manual model creation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜