title: Mongoose: Find subdocument from Mixed Type and update
body: <p>I want to Update and delete sub document. The structure of document as follows,</p>
  
  <pre><code>   {
    "projectId": "12345-service-request",
    "projectVersion": [{
      "version":"1",
      "localConfig": [{
        "port": "3003",
        "mongoURI": "mongodb://localhost:27017/serviceRequest",
        "MQ": "RMQ",
        "logLevel": "2",
        "version": "1.1",
        "created": "03-06-2018 03:11:00 PM",
        "active": "N"
      },
      {
        "port": "3004",
        "mongoURI": "mongodb://localhost:27017/serviceRequest",
        "MQ": "IMQ",
        "logLevel": "1",
        "version": "1.2",
        "created": "07-06-2018 03:11:00 PM",
        "active": "Y"
      }]    
    }]
  }
  </code></pre>
  
  <p>The fields in <strong>"localConfig"</strong> are not same, they are different as per project.
  So I have created schema using <strong>Schema.Types.Mixed</strong> for this as below,</p>
  
  <pre><code>const mongoose = require('mongoose');
  mongoose.set('debug', true);
  const Schema = mongoose.Schema;
  
  const projectVersion = new Schema({ 
      version: {type:String, required: true},
      cloudParams: [String],
      localConfig: [{type:Schema.Types.Mixed}]    // Mixed Type schema
  });
  
  const projectConfig = new Schema({
      projectId : {type:String, required: true},
      projectVersion : [projectVersion]
  });
  
  module.exports = mongoose.model("ProjectConfig", projectConfig);
  </code></pre>
  
  <p>Now, I am trying to find subdocument using condition, </p>
  
  <pre><code>projectId = 12345-service-request and
  projectVersion.localConfig.version = 1.2
  </code></pre>
  
  <p>But is returns complete document.
  Code to find sub document using <code>$ and $elemMatch</code>,</p>
  
  <pre><code>    let projectId = '12345-service-request';
      let version = '1.2'
      // Using $
      ProjectConfig.findOne({'projectId' : projectId,'projectVersion.localConfig.version' : version },
          { 'projectVersion.$' : 1 }).exec(function(err,projectConfig){
  console.log("Result : "+JSON.stringify(projectConfig)); 
          }); 
  </code></pre>
  
  <p>and</p>
  
  <pre><code>ProjectConfig.find({'projectId' : projectId,'projectVersion.localConfig.version' : version } , 
      { 'projectVersion.localConfig' : { $elemMatch : { version : version } } }).exec(function(err,projectConfig){
          console.log("Result : "+JSON.stringify(projectConfig));        
  }); 
  </code></pre>
  
  <p>I am missing something or is there any other way to find subdocument from Mixed type.</p>