title: returning all comments by a specific user without other document fields using mongoose
body: <pre><code>var mongoose = require('mongoose');
  
  // defines the database schema for this object
  var schema = mongoose.Schema({
    projectName : String,
    authorName : String
  
     comment : [{
        id : String,                                  
        authorName : String,
        authorEmailAddress : { type : String, index : true }  
      }]
    });
  </code></pre>
  
  <p><code>})</code></p>
  
  <pre><code>// Sets the schema for model
  var ProjectModel = mongoose.model('Project', schema);
  
  // Create a project
  exports.create = function (projectJSON) {
  
    var project = new ProjectModel({
  
      projectName : projectJSON.projectName ,
      authorName : projectJSON.authorName,    
  
      comment : [{
        id : projectJSON.comments.id,                                         
        authorName : projectJSON.comments.authorName,                         
        authorEmailAddress : projectJSON.authorEmailAddress
      });
  
    project.save(function(err) {
      if (err) {
        console.log(err);
      }
      else{
        console.log("success");
      }
    });
  
  
  }
  </code></pre>
  
  <p><strong>Q: i would like to retrieve all comments (without other document fields) a specific user made across all projects</strong></p>
  
  <p>My attempt:</p>
  
  <pre><code>// assuming email address is unique per user, as user can always change displayName for instance
  
  exports.allCommentsByUser = function(userEmail, callback){ 
      ProjectModel.find(
          {"comments.authorEmailAddress" : userEmail}, 
          { "projectName" : 1, "comments.authorEmailAddress" : 1 }, 
          callback);
  };
  </code></pre>