title: Cannot Populate path in Mongoose while trying to join two documents
body: <h3>MongooseError: Cannot populate path <code>loaned_to</code> because it is not in your schema. Set the <code>strictPopulate</code> option to false to override.</h3>
  <p>I've tried to join two documents in mongodb using mongoose in nodejs, But unfortunately this error occurs. My mongoose version is 6.0.6</p>
  <h4>Book Schema</h4>
  <pre><code>const mongoose = require('mongoose');
  
  const BookSchema = new mongoose.Schema({
      &quot;name&quot;: {type: String, required: true},
      &quot;author_name&quot;: {type: String, required: true},
      &quot;published_date&quot;: {type: Date, required: false},
      &quot;copies&quot;: [
          {
              &quot;isbn_number&quot;: {type: String, required: true},
              &quot;status&quot;: {type: String, required: true, default: &quot;Available&quot;},
              &quot;due_back&quot;: {type: Date, required: false},
              &quot;loaned_to&quot;: {type: mongoose.Schema.Types.ObjectId, required: false, ref: &quot;User&quot;}
          },
      ]
  })
  
  const Book = mongoose.model(&quot;Book&quot;, BookSchema);
  module.exports = Book;
  </code></pre>
  <h4>User Schema</h4>
  <pre><code>const mongoose = require('mongoose');
  
  const UserSchema = new mongoose.Schema({
      &quot;first_name&quot;: {type: String, required: true},
      &quot;last_name&quot;: {type: String, required: true},
      &quot;phone_number&quot;: {type:  String, required: true},
      &quot;address&quot;: {type:  String, required: false},
      &quot;user_name&quot;:{type: String, required: true},
      &quot;password&quot;: {type:  String, required: true},
      &quot;email&quot;: {type:  String, required: true},
      &quot;notifications&quot;: [
          {
              &quot;notification_id&quot; : {type:&quot;string&quot;, required:true},
              &quot;notification&quot;: {type: &quot;string&quot;, required: true}
          },
      ]
  })
  
  const User = mongoose.model(&quot;User&quot;, UserSchema);
  module.exports = User;
  </code></pre>
  <h4>My code to join documents</h4>
  <pre><code>exports.getAllBooks = async (req, res) =&gt; {
      try {
          let data = await BookModel.findOne().populate(&quot;loaned_to&quot;);
          res.status(200).send({data: [...data], success: true})
      } catch (err) {
          console.log(err)
          res.status(404).send({success: false, msg: err.message})
      }
  }
  </code></pre>