title: MongoDB get SubDocument
body: <p>I would like to retrieve a sub document from a document in MongoDB.  I have the following document:</p>
  
  <pre><code>{
      "_id" : "10000",
      "password" : "password1",
      "name" : "customer1",
      "enabled" : true,
      "channels" : [ 
          {
              "id" : "10000-1",
              "name" : "cust1chan1",
              "enabled" : true
          }, 
          {
              "id" : "10000-2",
              "name" : "cust1chan2",
              "enabled" : true
          }
      ]
  }
  </code></pre>
  
  <p>The result I would like is:</p>
  
  <pre><code>{
      "id" : "10000-1",
      "name" : "cust1chan1",
      "enabled" : true
  }
  </code></pre>
  
  <p>However, the best I can do so far is using the following query:</p>
  
  <pre><code>db.customer.find({"channels.id" : "10000-1"}, {"channels.$" : 1, "_id" : 0})
  </code></pre>
  
  <p>But this gives me the following result:</p>
  
  <pre><code>{
      "channels" : [ 
          {
              "id" : "10000-1",
              "name" : "cust1chan1",
              "enabled" : true
          }
      ]
  }
  </code></pre>
  
  <p>Does anyone know if it is possible to write a query that will give me my desired result?  Any help would be much appreciated.</p>