title: Cast to ObjectId failed for value "" at path "_id" for model
body: <p>I have already checked the other entries on <code>StackOverflow</code>, but it did not help.</p>
  
  <p>I am building a <code>RESTapi</code> with <code>node.js</code>, and I am using <code>MongoDB</code> with <code>mongoose</code>
  I have a <code>Schema</code> that contains three different models. I am able to save <code>POST</code> request to the entry. I am sure that entry is saved because I checked on <code>atlas.mongo</code>. However, I have a problem when I am trying to use <code>GET</code> request.</p>
  
  <p>It gives this error:</p>
  
  <blockquote>
    <p>Cast to ObjectId failed for value "" at path "_id" for model</p>
  </blockquote>
  
  <p>These are my <strong>Models</strong>: (These models are in different files) </p>
  
  <pre><code>const Model1 = mongoose.Schema({
      _id: mongoose.Schema.Types.ObjectId,
      word1: { type: [String], require: true }
  });
  ----------------------------------------------
  const Model2 = mongoose.Schema({
      _id: mongoose.Schema.Types.ObjectId,
      word2: { type: [String], require: true }
  });
  ----------------------------------------------
  const Model3 = mongoose.Schema({
     _id: mongoose.Schema.Types.ObjectId,
     element1: { type: [String],  default: ""},
     element2: { type: [String], default: ""}
  });
  ----------------------------------------------
  const Word = mongoose.Schema({
     _id: mongoose.Schema.Types.ObjectId,
     md3: { type: mongoose.Schema.Types.Mixed, ref: 'Model3', require: true },
     md2: { type: mongoose.Schema.Types.Mixed, ref: 'Model2', require: true },
     md1: { type: mongoose.Schema.Types.Mixed, ref: 'Model1', require: true }
  });
  </code></pre>
  
  <p>This is my <strong>POST</strong> request:</p>
  
  <pre><code>exports.entry_create = (req, res, next) =&gt; {
  const newModel3 = new Model3({
      _id: new mongoose.Types.ObjectId(),
      element1: req.body.element1,
      element2: req.body.element2
  });
  
  const newModel2 = new Model2({
      _id: new mongoose.Types.ObjectId(),
      word2: req.body.word2
  });
  
  const newModel1 = new Model1({
      _id: new mongoose.Types.ObjectId(),
      word1: req.body.word1
  });
  
  const newEntry = new Word({
      _id: new mongoose.Types.ObjectId(),
      md3: newModel3,
      md2: newModel2,
      md1: newModel1
  });
  
  newEntry
      .save(); // i have also then() and catch() part
  };
  </code></pre>
  
  <p>This is where I got the error on <code>Postman</code></p>
  
  <pre><code>exports.entry_get_all = (req, res, next) =&gt; {
  Word.find()
      .select('_id md3 md2 md1')
      .populate('md3')
      .populate('md2')
      .populate('md1')
      .exec()
      .then(docs =&gt; {
          res.status(200).json({
              numOfEntries: docs.length,
              Entries: docs.map(doc =&gt; {
                  return {
                      _id: doc._id,
                      md3: doc.md3,
                      md2: doc.md2,
                      md1: doc.md1,
                      request: { type: 'GET' }
                  }
              })
          });
      }); // i have also catch() part
  };
  </code></pre>
  
  <p>What could be the problem? Is <code>_id</code>'s of <code>md3, md2 &amp; md1</code> returns <code>null</code>?</p>