title: Mongodb, using aggregate combined with filter?
body: <p>I'm trying to convert a PHP script that is based in a mysql database to run it on a MongoDB database. I have resolved the major queries except one.</p>
  
  <p>Imagine i have a library (this is the collection), every document is a book entry. So I need to know how many distinct authors are in the library wroten in a certain language (another field).</p>
  
  <p>At the moment I have that code and I don't know how to continue:</p>
  
  <pre><code>$test = array(
      array(
          '$group' =&gt; array(
              '_id' =&gt; array('author' =&gt; '$author' )
          )
      )
  );
  $out = $db-&gt;$collection-&gt;aggregate($test);  
  </code></pre>
  
  <p>Thanks.</p>