Hello,

I'd like to find a way to automagically extend data a model dataset returns 
with some related eager loaded table.

I have a model as this (simplified) :

class Foo < Sequel::Model
  many_to_one :bar, :select => [:id, :field1, :field2]
end


And I'd like to retrieve the data like this :

foo_set = Foo.dataset.eager(:bar).all
# => [{:id => 1, :bar => {:id => 32, :field1 => "value", :field2 => 
"value"}}, ...]


What am i missing to actually add the eager loaded bar data into the result 
dataset?
I'd like to avoid post processing loops and make something generic, in the 
model file maybe.

Subsidiary questions :

- What if nested eager loading, how to have the same results? :
ber_set = Ber.dataset.eager(:foo => :bar).all
# =>[{:id => 3, :foo => {:id => 1, :bar => {:id => 32, :field1 => "value", 
:field2 => "value"}}}, ...]


- How to also apply that to a single table resource like :
foo = Foo[4]
# => {:id => 1, :bar => {:id => 32, :field1 => "value", :field2 => "value"}}

Thanks for your help

-- 
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 http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to