title: How to perform a "Distinct" MongoDB query on MongoDB Atlas using Stitch
body: <p>I'm building an Android app, and using the MongoDB Atlas service as my database.  It's my first time using MongoDB and I'm surprised at how weak the documentation is.  </p>
  
  <p>MongoDB requires me to use the stitch client libraries to interface with the Atlas service.  I'm using the latest 'org.mongodb:stitch:0.1.0-SNAPSHOT' library  Their example/pattern for performing a FIND is like this...</p>
  
  <pre><code> Document query = new Document()
              .append(Review.Field.RESTAURANT_ID, restaurant.getId())
              .append(Review.Field.OWNER_ID, getUserId());
  
     getDatabase().getCollection(DBCollections.REVIEWS_RATINGS).find(query).continueWith...
  </code></pre>
  
  <p>I'm trying to perform a "Distinct" command as described <a href="https://docs.mongodb.com/manual/reference/command/distinct/#dbcmd.distinct" rel="nofollow noreferrer">here</a>.  It looks like the only method I have for getting info from Mongo is the FIND method, and it looks like the only way I have to customize the query is by altering the query document that I build and send along with the method call.  If I create a query document like this...</p>
  
  <pre><code> Document query = new Document()
              .append("distinct","Restaurants")
              .append("key","type");
  </code></pre>
  
  <p>...it comes back blank.  I want it to return an array of unique restaurant types (Strings) from that collection.</p>
  
  <p>I could perhaps use a pipeline, but that documentation is even more lacking that the documentation for the Stitch libraries.  I've tried both Find and Aggregate queries using the Debug console in the Stitch console.  It looks like a helpful debugging tool, but it requires the queries to be in a JSON format, and again I haven't found any documentation that describes how to format a query into the JSON schema they want. </p>
  
  <p>I'm hoping someone can show me how to accomplish a "Distinct" MongoDB query on MongoDB Atlas using Stitch.</p>