title: Pouchdb Combining Data from Multiple Databases in map function
body: <p>I have an Database with docs and another with categories now I want to combine booth in an map reduce view like:</p>
  
  <pre><code>var categoryMapper = [...]
  var viewName = 'byMonthAndCat10';
  var index = {
      _id: '_design/'+viewName,
      views: {
          byMonthAndCat10: {
              map: function (doc) {
                  if (doc.bookingDate) {
                      var date = moment(doc.bookingDate, moment.ISO8601_FORMAT);
                      categoryMappers.forEach(function(mapper) {
                          if(doc[mapper.field].indexOf(mapper.value)) {
                              emit([date.year(), date.month(), date.day()], [mapper.category, doc.debit+doc.credit]);
                          }
                      });
                  }
              }.toString()
          }
      }
  };
  </code></pre>
  
  <p>But the map function is stringified and so doesn't know about categorymapper anymore. How do I handle this? I could prepend the categorymapper array as string but that's not very nice, or?</p>