title: Mongoose ignoring field while trying to save
body: <p>I am trying to insert a new entry in my collection, the problem is that it ignores both <strong>doctorId</strong> and <strong>patientId</strong> while I'am sure they are not undefined. I tried to change the fields types in the definition to strings just to test whether they would be inserted and it still no use.</p>
  <p>schema:</p>
  <pre class="lang-js prettyprint-override"><code>const RdvSchema = new mongoose.Schema({
      patientId: {
          type: mongoose.Schema.Types.ObjectId,
          ref: &quot;patients&quot;
      },
      doctorId: {
          type: mongoose.Schema.Types.ObjectId,
          ref: &quot;doctors&quot;
      },
      createdAt: {
          type: Date,
          default: () =&gt; Date.now()
      },
      updatedAt: {
          type: Date,
          default: () =&gt; Date.now()
      },
      urgent: {
          type: Number,
          default: () =&gt; false
      },
      date: Date,
      period: String,
      description: String
  })
  </code></pre>
  <p>the function saving the document:</p>
  <pre class="lang-js prettyprint-override"><code>const createRdv = async (req, res) =&gt; {
      try {
          console.log(&quot;patient id: &quot;, req.body.patientId)
          let rdv = new Rdv({
              &quot;patientId&quot;: req.body.patientId,
              &quot;doctorId&quot;: req.body.doctorId,
              &quot;description&quot;: req.body.description,
              &quot;urgent&quot;: req.body.urgent,
              &quot;date&quot;: req.body.date,
              &quot;period&quot;: req.body.period
          })
          await rdv.save(async (err, rdv) =&gt; {
              if (err) {
                  console.log(err)
                  return res.status(500).send(false)
              }
              try {
                  await DoctorRepository.addRdv(req.body.doctorId, rdv._id)
                  await PatientRepository.addRdv(req.body.patientId, rdv._id)
              } catch (message) {
                  console.log(message)
                  res.status(500).send(false)
              }
          })
          res.status(200).send(true)
      } catch (ex) {
          res.status(500).send(false)
      }
  }
  </code></pre>
  <p>The inserted document:</p>
  <pre class="lang-js prettyprint-override"><code>{
    &quot;_id&quot;: {
      &quot;$oid&quot;: &quot;6269603d5f0e45e53a470f50&quot;
    },
    &quot;urgent&quot;: 3,
    &quot;date&quot;: {
      &quot;$date&quot;: {
        &quot;$numberLong&quot;: &quot;1653433200000&quot;
      }
    },
    &quot;period&quot;: &quot;matin&quot;,
    &quot;description&quot;: &quot;this is a description&quot;,
    &quot;createdAt&quot;: {
      &quot;$date&quot;: {
        &quot;$numberLong&quot;: &quot;1651073085661&quot;
      }
    },
    &quot;updatedAt&quot;: {
      &quot;$date&quot;: {
        &quot;$numberLong&quot;: &quot;1651073085661&quot;
      }
    },
    &quot;__v&quot;: 0
  }
  </code></pre>
  <p><strong>update</strong>: for some reason An old document keeps getting inserted the document has nothing to do with what I was trying to insert. The document is one I had inserted previously through a test using Mocha</p>