exAspArk / batch-loader

:zap: Powerful tool for avoiding N+1 DB or HTTP queries
https://engineering.universe.com/batching-a-powerful-way-to-solve-n-1-queries-every-rubyist-should-know-24e20c6e7b94
MIT License
1.04k stars 52 forks source link

How I can filter associations values? #70

Closed kalfaro closed 4 years ago

kalfaro commented 4 years ago

Example: I have Users with a type attribute like reader and this users have Posts with a different states

I need to select only users with specific type attribute and the Post with a specific type... So basically filter the associations values

I hope the explanation was clear Thanks for the help!

tabuchid commented 4 years ago

@kalfaro Did you figure out how to make this work?

kalfaro commented 4 years ago

@tabuchid Yes, I found a solution, but I'm not sure if is the best approach

I implement a 'Resolver' on child records and pass params from father using 'scoped_context', with this I can create custom queries depends of params

Please, let me know if exist others solutions for this I appreciate the help! Thanks