title: updating a referenced field in mongodb mongoose
body: <p>I am trying to "clear" my referenced field in my mongo db. 
  I am using mongoose, so i have a modelSchema like this.</p>
  
  <pre><code>const usersSchema = new Schema({
  
      userName: { type: String, required: true },
      password: { type: String, required: true },
      isAdmin: { type: Boolean },
      email: { type: String },
      profile: {
          type: mongoose.Schema.Types.ObjectId,
          ref: 'profiles'
      }
  })
  </code></pre>
  
  <p>So my question is... if i already have an objectId added in my profile field...
  how can i clear that field? </p>
  
  <p>I am receiving from my client an update request with a json like this.</p>
  
  <pre><code>{ userName: 'admin',
    password: '123',
    email: 'admin@admin.com',
    profile: '',
    isAdmin: true }
  </code></pre>
  
  <p>and my controller do this.</p>
  
  <pre><code>usersCtrl.updateUser = (req, res) =&gt; {
  
      userModel.findByIdAndUpdate(req.params.id, { $set: req.body }).then(() =&gt; {
          res.json('updated')
      }).catch((err) =&gt; {
          console.log(err)
          res.json(err)
      })
  }
  </code></pre>
  
  <p>but i get this error</p>
  
  <blockquote>
    <p>CastError: Cast to ObjectId failed for value "" at path "profile"</p>
  </blockquote>
  
  <p>thanks in advance</p>