title: How to find in mongoose with deep population?
body: <p>I succeed to make a deep population with find and the search key in first model, but now i want to find by key on the sub object generated by the deep populate.</p>
  
  <p>I have three models : Product, Category, and Event</p>
  
  <p>I want to find my Products by <strong>e_fk_club_id</strong> that is in <strong>Event</strong> model</p>
  
  <p>I tried two solutions but they didn't work</p>
  
  <p>First solution in find : </p>
  
  <pre><code>model.find({'categories.events.e_fk_club_id':id})`
  </code></pre>
  
  <p>Second solution with match :</p>
  
  <pre><code> `$match : { e_fk_club_id : id }`
  </code></pre>
  
  <p>these are my models</p>
  
  <p><strong>product.js</strong></p>
  
  <pre><code> var ProductSchema = new mongoose.Schema({
  
          p_id: Number,
          p_name: String,
          p_fk_category: {type: mongoose.Schema.Types.ObjectId, ref: 'categories'},
  
      }
      ,  {collection: 'products'});
  
  
  module.exports = mongoose.model('products', ProductSchema);
  </code></pre>
  
  <p><strong>Category.js</strong></p>
  
  <pre><code> var CategorySchema = new mongoose.Schema({
  
              c_id: Number,
              c_name: String,
              c_fk_event: {type: mongoose.Schema.Types.ObjectId, ref: 'events'},
  
          }
          ,  {collection: 'categories'});
  
  
      module.exports = mongoose.model('categories', CategorySchema);
  </code></pre>
  
  <p><strong>Event.js</strong></p>
  
  <pre><code> var EventSchema = new mongoose.Schema({
  
              e_id: Number,
              e_name: String,
              e_fk_club_id: Number,
  
          }
          ,  {collection: 'events'});
  
  
      module.exports = mongoose.model('events', EventSchema);
  </code></pre>
  
  <p>This is the code which i am trying to fetch the data : </p>
  
  <pre><code>getProductsByClub:function (id, callback){
              var model = require("Product");
  
  
              //model
              model .find({'categories.events.e_fk_club_id':id})
  
              .populate({
                  path:'p_fk_category',
                  model:'categories',
                  populate:
                      {
                      path:'e_fk_event',
                          model:'events',
                          //$match : { e_fk_club_id : id }
                  }
              })
  
  
  
  
                  .exec (function(err, doc){
                      if (err) {
  
                          callback(err) ;
  
                      } else {
                          callback(doc) ;
  
                      }
                  })
          },
  </code></pre>
  
  <p>Is There any solution.</p>
  
  <p>Thank you in advance.</p>