Class: Mongoid::Association::EagerLoad::OtherDatabaseTargets Private
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
self,
PolymorphicTargets
|
|
|
Instance Chain:
self,
PolymorphicTargets
|
|
| Inherits: |
Mongoid::Association::EagerLoad::PolymorphicTargets
|
| Defined in: | lib/mongoid/association/eager_load/polymorphic_targets.rb |
Overview
Targets kept in another database (or cluster), which a $lookup cannot reach. Each type is read directly through its own model, which connects with that model's client.
For { 'Scanner' => [ id2 ] } it runs, on the Scanner model's own client:
scanners.find('_id' => { '$in' => [ id2 ] })
Class Method Summary
PolymorphicTargets - Inherited
| .for | Resolve every polymorphic target for the foreign keys grouped by type. |
| .new, | |
| .in_root_database? | Whether the type's model shares the root's database (and client): exactly what a $lookup from the root collection can reach. |
Instance Method Summary
- #fetch ⇒ Hash Internal use only
PolymorphicTargets - Inherited
| #fetch, | |
| #indexed | The raw documents instantiated and indexed by their primary key. |
| #model_for, #primary_key | |
Constructor Details
This class inherits a constructor from Mongoid::Association::EagerLoad::PolymorphicTargets
Instance Method Details
#fetch ⇒ Hash
# File 'lib/mongoid/association/eager_load/polymorphic_targets.rb', line 141
def fetch @keys_by_type.to_h do |type, keys| model = model_for(type) documents = model.collection.find(primary_key => { '$in' => keys.uniq }) [ type, indexed(documents, model) ] end end