gpt4 book ai didi

ruby - DataMapper Redis : can't find child from parent, 只有来自 child 的 parent

转载 作者:可可西里 更新时间:2023-11-01 11:22:50 26 4
gpt4 key购买 nike

我在 Ruby 库中使用 DataMapper 和 redis 适配器。

我定义了这些类:

class Zone

include DataMapper::Resource

property :id, String, :key => true, :unique_index => true, :default => lambda { |x,y| UUID.new.generate }
property :preview_mode, Boolean, :default => false

timestamps :at

has 1, :campaign
end

class Campaign

include DataMapper::Resource

property :id, String, :key => true, :unique_index => true, :default => lambda { |x,y| UUID.new.generate }
property :name, String

timestamps :at

belongs_to :zone
has n, :rules

validates_presence_of :name
end

我可以做 Campaign.first.zone 但不能做 Zone.first.campaign。

我希望能够在两个方向上进行查找。

最佳答案

@lightyrs 我回复了你的 github 问题,但作为引用,我认为这个问题已经在版本 > 0.8 中得到修复,该版本对非串行主键有更好的支持。

干杯! - 机器人

关于ruby - DataMapper Redis : can't find child from parent, 只有来自 child 的 parent ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10145851/

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