dynamoid
dynamoid copied to clipboard
preload associations
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.
Hi, indeed preloading isn't implemented. But it sounds like a cool (but toilful) feature. Will add it to the TODO list.