title: mongoose - Cast to number failed for value "[object Object]" at path
body: <p>I have a schema that looks like this:</p>
  
  <pre><code>module.exports = mongoose.model('Buyer',{
      username: String,
      password: String,
      email: String,
      url: String,
      id: String,
      firstName: String,
      lastName: String,
      credit: Number,
  });
  </code></pre>
  
  <p>I am trying to add to their credit whenever they submit a Stripe payment, but when I do, I get the error that is in the title:</p>
  
  <pre><code>Cast to number failed for value "[object Object]" at path
  </code></pre>
  
  <p>Here is where I try to update <code>credit</code>:</p>
  
  <pre><code>    var query = Buyer.findOne({'_id': req.user._id});
      query.exec(function(err,buyer){
          buyer.credit = { credit: parseInt(req.body.amount,10) };
          buyer.markModified('credit');
          buyer.save(function (err) {
              if (!err) {
                  //--NO ERROR
              } else {
                return console.log(err);
              }
          });
      });
  </code></pre>
  
  <p>I'm not sure how to add to existing credit, instead of overwriting it as I'm doing above, but I suppose I'll ask that in another question after looking further into it.</p>
  
  <p>Anyways, I don't understand what is going on with my error. I tried doing it without the <code>parseInt</code> but noticed it was a string. </p>