On 5 janvier 2016 at 23:37:53, Jeremy Evans ([email protected]) wrote:

>  
> plugin :many_through_many
> many_through_many :related_videos, [[:video_keywords, :video_id,
> :keyword_id], [:keywords, :id, :id], [:video_keywords, :keyword_id,
> :video_id]]
>  
> That's simpler and should provide you with a working eager loader.
> 

Yep this works, for some reason I didn't think [:keywords, :id, :id] would work.

Also thanks for the eager loader docs, for some reason I didn't find it (and 
Google keep correcting sequel to SQL which is a major pain when searching).

Full code I used for reference:

  plugin :many_through_many
  many_through_many :related_videos,
    [[:video_keywords, :video_id, :keyword_id],
     [:keywords, :id, :id], 
     [:video_keywords, :keyword_id, :video_id]],
    class: self, distinct: true,
    after_load: proc {|vid, related_vids| related_vids.delete(vid) }

Cheers

--  
Nicolas Goy
Programmer

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