title: Mongoose Error while performing delete
body: <p>I am running into following error but I unable to completely grasp the understanding behind the error.</p>
  
  <pre><code>CastError: Cast to ObjectId failed for value "XYZ" at path "_id" for model "Partner"
  </code></pre>
  
  <p>I have my schema defined as following</p>
  
  <pre><code>var partnerList = new Schema (
      {
          partnerName: String,
          supportedProducts: [String]
      },
      {
          collection: 'partnerList'
      }
  );
  
  module.exports = mongoose.model('Partner', partnerList);
  </code></pre>
  
  <p>The functionality of my delete function </p>
  
  <pre><code>delete: function (req, res) {
      var removePartner = req.params.partnerName;
      var promise = Partner.findByIdAndRemove(removePartner).exec();
      promise.then(function removePartner(val) {
          console.log('partner value removed');
          res.send(val);
      }).catch(function catchError(err){
          console.error(err);
          throw err;
      });
  }
  </code></pre>
  
  <p>I am trying to making a request to my node app service using 
  <strong>localhost:8443/data/XYZ</strong>, where i am passing the value 'XYZ' as the parameter. This value is used to delete the appropriate object from the database. </p>