Thanks! Also, had an additional idea to create a dataset method as well, so you could do:
school.users_dataset.book_pks_dataset and it would automatically put a distinct on it by default and return all those book_pks into a query that you could reuse. On Saturday, May 30, 2020 at 8:33:26 PM UTC+3, Jeremy Evans wrote: > > On Saturday, May 30, 2020 at 4:58:47 AM UTC-7, Aryk Grosz wrote: >> >> Often times, I want to return the IDs from an association only to use it >> in another query. >> >> For example, say you have a many to many like User has many Books. >> >> With association_pks plugin, you can do user.book_pks and get back an >> actual array, but if you are returning potentially 300 IDs and then >> throwing that into another query, that query will get unnecesarily long >> (imagine repeating this a few times). >> >> I noticed that in the association_pks plugin, you are running select_map >> on all your datasets. Perhaps at that last step, we could simple "select' >> that column and create a new method <association>_pks_dataset to just >> return the dataset. >> >> It wouldn't add a lot of new code/logic, but increase flexibility of that >> plugin. >> >> Thoughts? >> > > This seems like a useful feature addition, I'll add it to my todo list. > > 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 view this discussion on the web visit https://groups.google.com/d/msgid/sequel-talk/02fb7c72-b1e2-4a13-8a37-1148e14102bc%40googlegroups.com.
