title: How to query PouchDB with SQL-like operators
body: <p>Being relatively new to PouchDB/CouchDB, I'm still trying to wrap my head around how to use the map/reduce correctly in different cases.</p>
  
  <p>Supposed that I have document structure like this:</p>
  
  <pre><code>{
    _id: 'record/1',
    labels: {
      // many-to-many relationship
      'label/1': true, // let's assume that this is 'Label A'
      'label/3': true, // 'Label C'
      'label/4': true // 'Label D'
    }
  },
  {
    _id: 'record/2',
    labels: {
      'label/1': true, // 'Label A'
      'label/2': true // 'Label B'
    }
  }
  </code></pre>
  
  <p>What are the correct ways to define view for <code>db.query</code> function to search:</p>
  
  <ol>
  <li>records with 'Label A' <strong>or</strong> 'Label B'</li>
  <li>records with 'Label A' <strong>and</strong> 'Label B'</li>
  </ol>