I figured it out finally. The answer was using eager:
def uncategorized_articles
Article.eager(categories: proc { |dataset| dataset.where { categories.count
== 0 } })
end
On Monday, April 25, 2016 at 2:32:51 AM UTC-7, Brandon Conway wrote:
>
> I have:
>
> class Article < Sequel::Model
> many_to_many :categories
> end
>
>
> class Category < Sequel::Model
> many_to_many :articles
> end
>
>
> I can't for the life of me figure out how to find all articles with no
> associated categories (in a single query, I obviously don't want to iterate
> through each article checking the count). It seems like this should be very
> easy.
>
> Thanks in advance,
> Brandon
>
--
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.