On 8/21/2018 3:57 PM, Jeff Dyck wrote:
I'm trying to pull a list of a specified number of users (10 in this example) from specific site, in a specific grade, that don't already have an assigned device. I can easily get a list of the users by site & grade, but I haven't had any success trying to filter it only to users without devices.
If you're only ever looking for users that have exactly zero devices, then you can skip the aggregate. Performing a LEFT JOIN while looking for nulls in the joined table accomplishes this. And in Sequel, since eager_graph performs a LEFT OUTER JOIN:
User.eager_graph(:device).where(:site=> siteid, :grade => grade, Sequel[:device][:id] => nil).first(10)
-John -- 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.
