如何在google appengine上的jruby上的datamapper中使用list/array作为属性?

最佳答案

这就像has..and..属于..many一样,没有连接表…

class Person
  include DataMapper::Resource
  property :id,          Serial
  property :name,        String, :nullable => false
  property :project_ids, List
  timestamps :at
  # project should be flagged as archived, not deleted
  def projects
    Project.all(:id => project_ids)
  end
end

class Project
  include DataMapper::Resource
  property :id,          Serial
  property :name,        String, :nullable => false
  property :archived,    Boolean, :default => false
  # the join table is bolted onto the person model
  def people
    Person.all(:project_ids => id)
  end
end

关于ruby - App Engine Jruby DataMapper列表属性,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1547601/

10-16 01:22