title: Mongoose save() after find, findOne, or findById
body: <p>I'm having trouble with using save() after updating a mongoose document. It looks like the type passed from find, findOne, or findById is a Mongoose Document not a model so it lacks the save() function. update() is available, but it skips the middleware, which I need.</p>
  
  <p>Closest I could find is this:
  <a href="https://stackoverflow.com/questions/15377495/mongoose-save-method-does-not-exist">mongoose - &#39;save&#39; method does not exist</a> but is looks like it still passes a Document to me not a Model instance.</p>
  
  <p>Is it maybe my version? Using the latest in NPM - 3.8.1</p>
  
  <pre><code>models.StudySubject.findById(id, function (err, studySubject) {
          if (err)
              return cb(err);
  
          if (!studySubject)
              return cb({ status: 404, error: 'Study subject not found'});
  
          var subjectInfo = extractSubjectFields(params);
          delete subjectInfo.study; // prevent study change
  
          updateObjOneLevel(studySubject, subjectInfo);
  
          studySubject.save(function (err, studySubject, count) {
              if (err)
                  return cb(err);
  
              if (count !== 1)
                  return cb({ status: 500, error: 'Error saving Study Subject' });
  
              cb(null, studySubject);
          });
      });
  </code></pre>
  
  <p><code>extractSubjectFields()</code> looks at the input <code>params</code> for optional update fields like:</p>
  
  <pre><code>if (params.study)
          subjectInfo.study = params.study;
  </code></pre>
  
  <p>Stacktrace:</p>
  
  <pre><code>Uncaught TypeError: Object #&lt;Object&gt; has no method 'save'
   at C:\....\node_modules\mongoose\lib\document.js:1270:13
  </code></pre>
  
  <p>Schema:</p>
  
  <pre><code>var studySubjectSchema = new mongoose.Schema({
      _id: {
          type: String,
          default: function() { return uuid.v4() },
          match: [/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/, "Invalid UUID"]
      },
      study: {
          type: String,
          ref: 'Study',
          required: "Study reference is required: `{PATH}` - `{VALUE}`"
      },
      first_name: {
          type: String,
          encrypt: true
      },
      last_name: {
          type: String,
          encrypt: true
      },
      date_of_birth: {
          type: String,
          encrypt: true
      },
      mrns: [MRNSchema],
      metadata: {
          type: {},
          validation: [function (val) {
              return (typeof val == 'object');
          }, "Metadata field must be a key/value object"]
      },
      enrollments: [{
          type: String,
          match: [/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/, "Invalid Enrollment UUID"],
          ref: 'Enrollment'
      }]
  });
  
  var enrollmentSchema = new mongoose.Schema({
      _id: {
          type: String,
          default: function() { return uuid.v4() },
          lowercase: true,
          match: [/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/, "Invalid UUID"]
      },
      study: {
          type: String,
          ref: 'Study',
          required: "Study reference is required: `{PATH}` - `{VALUE}`"
      },
      first_name: {
          type: String,
          required: true
      },
      last_name: {
          type: String,
          required: true
      },
      date_of_birth: {
          type: String,
          required: true
      },
      mrns: [MRNSchema],
      metadata: {
          type: {},
          validation: [function (val) {
              return (typeof val == 'object');
          }, "Metadata field must be a key/value object"],
      },
      consents: [ConsentSchema],
      subject_study_code: {
          type: String,
          index: true
      },
      unenrolled: {
          type: Date
      }
  });
  </code></pre>
  
  <p>Thanks!</p>