title: Select a field in an array inside mongodb and display only unique field
body: <p>Will need select a field in an array inside mongodb. </p>
  
  <pre><code>{
  "_id" : ObjectId("53dbb05fa976627439d43884"),
  "employee" : [ 
      {
          "dateJoin" : "1986-03-10",
          "deptName" : "x",
  
      }, 
      {
          "dateJoin" : "1986-12-11",
          "deptName" : "y",
  
      },
   {
          "dateJoin" : "1986-12-11",
          "deptName" : "y",
  
      }
   ]
   }
  </code></pre>
  
  <p>In my case I would like select all the unique deptName available. The output is something like below.</p>
  
  <pre><code>  { deptName:x,
     deptName:y }
  </code></pre>
  
  <p>So far I have tried the below command but no luck.</p>
  
  <pre><code>db.employee.find( {},{ employee.deptName:1})
  </code></pre>