title: Return unique values by key in CouchDB
body: <p>Is there a way to do the following in CouchDB? A way to return unique, distinct values by a given key?</p>
  
  <pre><code>SELECT DISTINCT field FROM table WHERE key="key1"
  
  'key1' =&gt; 'somevalue'
  'key1' =&gt; 'somevalue'
  'key2' =&gt; 'anotherval'
  'key2' =&gt; 'andanother'
  'key2' =&gt; 'andanother'
  </code></pre>
  
  <p>For example:</p>
  
  <p><a href="http://localhost:5984/database/_design/designdoc/_view/distinctview?key=" rel="noreferrer">http://localhost:5984/database/_design/designdoc/_view/distinctview?key=</a>"key1" would return ['somevalue']</p>
  
  <p><a href="http://localhost:5984/database/_design/designdoc/_view/distinctview?key=" rel="noreferrer">http://localhost:5984/database/_design/designdoc/_view/distinctview?key=</a>"key2" would return ['anotherval', 'andanother']</p>