Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preload associations #547

Open
mrkamel opened this issue Apr 28, 2022 · 1 comment
Open

preload associations #547

mrkamel opened this issue Apr 28, 2022 · 1 comment

Comments

@mrkamel
Copy link
Contributor

mrkamel commented Apr 28, 2022

Hi!

Tt seems it's not possible to preload associations (didn't find it in the docs, code and github issues), but it would be highly valuable for e.g. belongs_to associations. Example:

class Company
  include Dynamoid::Document
end

class Product
  include Dynamoid::Document

  belongs_to :company
end

When i do:

Product.all.map(&:company).map(&:uuid).to_a it requests each company individually (typical N+1 issue). It would be nice to be able to Product.preload(:company).map(&:uuid).to_a such that the companies are loaded with a single query like usually the case when using ActiveRecord. Maybe i miss something.

Thanks in advance.

@andrykonchin
Copy link
Member

Hi, indeed preloading isn't implemented. But it sounds like a cool (but toilful) feature. Will add it to the TODO list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants