Mongoose: TypeError: doc.validate is not a function
<h2>Scenario</h2>

<p>I have a mongoose model schema as in the following:</p>

<pre><code>var TerminalBalanceSchema = new mongoose.Schema({
    currentBalances: [{
        terminalID: {
            type: String,
            // required: '{path} is required'
        },
        balance: {
            terminal: {
                type: Number,
                required: '{path} is required'
            },
            calculated: {
                type: Number,
                required: '{path} is required'
            }
        },
        lastInquiryDate: Date
    }]
});
</code></pre>

<p>where <code>currentBalances</code> is an array of objects.</p>

<p>The collection for the mongoose model <code>TerminalBalance</code> based on the above schema always contains a <strong><em>single object</em></strong> where only the items in <code>currentBalances</code> array may change.</p>

<h1>Problem</h1>

<p>Whenever I perform something to <strong><em>replace</em></strong> an object within the array <code>currentBalances</code> of the document, and eventually save the same document, I get the following error:</p>

<blockquote>
<pre><code>x:\node\mynps-tcp-server\node_modules\mongoose\lib\schema\documentarray.js:104
  doc.validate({ __noPromise: true }, function(err) {
      ^

TypeError: doc.validate is not a function

at x:\node\mynps-tcp-server\node_modules\mongoose\lib\schema\documentarray.js:104:11
at DocumentArray.SchemaType.doValidate (x:\node\mynps-tcp-server\node_modules\mongoose\lib\schematype.js:654:22)
at DocumentArray.doValidate (x:\node\mynps-tcp-server\node_modules\mongoose\lib\schema\documentarray.js:77:35)
at x:\node\mynps-tcp-server\node_modules\mongoose\lib\document.js:1171:9
at nextTickCallbackWith0Args (node.js:452:9)
at process._tickCallback (node.js:381:13)
</code></pre>
</blockquote>

<p>Note that to replace an object, I loop over the <code>currentBalances</code> array and if the object is the same as the one I'm looking for, I replace it:</p>

<pre><code>for (var i = 0; i &lt; terminalBalance.currentBalances.length; i++) {
     if(terminalBalance.currentBalances[i].terminalID === response.data.terminalID){
         terminalBalance.currentBalances[i] = balance;
         terminalBalance.save(function (err) {
             console.log('err', err); // this `err` is never thrown, that is the above error is thrown before reaching here 
         });
         break;
      } else { ...
</code></pre>

<blockquote>
  <p><strong>Mongoose version:</strong> 4.4.19</p>
</blockquote>