Thanks Jeremy, although I'm struggling to get the #graph_each method to 
work; I don't think I'm using it right. Can you give me an example on how 
to use this on a dataset, and how to use it on a model instance, e.g.

Property[property_id].to_hash #=> {property_id: 1, baz: "blah", owner: {name
: "John", postal_address: "5 Archer St, Downtown VG 3533"}}



On Tuesday, 22 August 2017 12:01:29 UTC+10, Jeremy Evans wrote:
>
> On Monday, August 21, 2017 at 6:00:44 PM UTC-7, Tom Wardrop wrote:
>>
>> This should be relatively trivial, but I'm having trouble working this 
>> out.
>>
>> I have two models with a one_to_one relationship, one is "property" and 
>> the other "owner". How would I get the following out of Sequel?
>>
>> [
>>   {property_id: 1, baz: "blah", owner: {name: "John", postal_address: "5 
>> Archer St, Downtown VG 3533"}},
>>   {property_id: 2, baz: "bleh", owner: {name: "Steven", postal_address: "32 
>> Buchanan Rd, Uptown FA 1123"}},
>>   ...
>> ]
>>
>> I typically use #naked to get an array of hashes, but can't seem to work 
>> out how to get that :owner sub-hash. Doing an #association_join(:owner) gets 
>> the owner details, but flattens it out into a single merged property/owner 
>> hash. I don't get a nice :owner sub-hash out of it.
>>
>> Can someone point me in the right direction here?
>>
>
> The graph_each plugin can do this.  If you are using PostgreSQL, you can 
> also use the pg_row and pg_row_ops extension to do so.
>
> Thanks,
> Jeremy
>

-- 
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.

Reply via email to