Hey. So I have a one-to-many relationship from Vendor to VendorRevision. I
want to grab all of the user's Vendors and the latest VendorRevision for
each without doing an N+1 sort of thing. Here's what I've been trying, but
nothing is working so far.
class Vendor < Sequel::Model
one_to_many :vendor_revisions, class: VendorRevision
many_to_one :user
end
Vendor.one_to_one :last_edit, :class => :VendorRevision
class VendorRevision < Sequel::Model
many_to_one :vendor
end
Then, when I try to do the query:
vendors = Vendor
.where(:user_id => 1)
.eager(:last_edit => proc {|ds|
ds.reverse_order(:created_at).clone(:eager_limit => 1) })
.all
vendors.each do |v|
p v.last_edit
p '-'*50
end
That just prints *nil* twice. I've tried it without the eager load, with
doing it as a one_to_many, but nothing's working. Any ideas?
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.