On Thursday, November 9, 2017 at 10:43:10 AM UTC-8, [email protected] wrote: > > I've run into an issue a few times where I want to efficiently fetch an > association for an array of models, but I can't because the models are > already in memory. > > class Artist < Sequel::Model > one_to_many :albums > end > > class Album < Sequel::Model > many_to_one :artist > end > > > Eager loading normally works like this: > > albums_with_artists = Album.where(id: [1, 2, 3]).eager(:artist) > > But a method may return an array of models, in which case I would want to > do something like: > > albums_without_artists = Album.where(id: [1, 2, 3]).all > > # Efficiently loads the :artist association for each Album in > albums_without_artists > Album.eager(albums_without_artists, :artist) > > Does Sequel currently have support for doing this? >
You probably want to use the tactical_eager_loading plugin. 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 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.
