title: Mongoose save with promises and populate
body: <p>I have the following code (Mongoose has been promisified with Bluebird)</p>
  
  <pre><code>function createNewCourse(courseInfo, teacherName) {
      var newCourse = new courseModel({
          cn: courseInfo.courseName,
          cid: courseInfo.courseId
      });
  
      return newCourse.saveAsync()
          .then(function (savedCourse) {
              var newTeacher = new newTeacherModel({
                  na: teacherName,
                  _co: savedCourse._id // This would be an array
              });
  
              return newTeacher.saveAsync().then(function() {
                  return newCourse;
              });
          });
  }
  </code></pre>
  
  <p>This is a simplification of my problem, but it illustrates it well. I want my createNewCourse function to return a promise that, once resolved, will return the newly saved course, <em>not</em> the teacher. The above code works, but it's not elegant and does not use promises well to avoid callback hell.</p>
  
  <p>Another option I considered is returning the course and then doing a populate, but that would mean re-querying the database.</p>
  
  <p>Any ideas how to simplify this?</p>
  
  <p><strong>Edit</strong>: I thought it might be useful to post the save code but using native callbacks (omitting error-handling)</p>
  
  <pre><code>function createNewCourse(courseInfo, teacherName, callback) {
      var newCourse = new courseModel({
          cn: courseInfo.courseName,
          cid: courseInfo.courseId
      });
  
      newCourse.save(function(err, savedCourse) {
          var newTeacher = new newTeacherModel({
              na: teacherName,
              _co: savedCourse._id // This would be an array
          });
  
          newTeacher.save(function(err, savedTeacher) {
              callback(null, newCourse);
          });
      });
   }
  </code></pre>