gpt4 book ai didi

ruby - App Engine Jruby DataMapper 列表属性

转载 作者:数据小太阳 更新时间:2023-10-29 08:34:59 25 4
gpt4 key购买 nike

如何在 Google AppEngine 上的 Jruby 上的 DataMapper 中使用列表/数组作为属性?

最佳答案

这将像 has..and..belongs..to..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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com