title: couchdb how to get doc by id in map function
body: <p>Suppose we have two types of documents. One - stores meta data, many others - have complicated processing, depending on the state of the first document. We do not want to duplicate the state in all documents of the second type because lots of them. How to develop MAP function to receive data from the first-type document.</p>
  
  <pre><code>{ "_id":"123",
     "public":true 
  }
  {
  "_id":"321",
  "owner_id":"123"
  "data":"..."
  }
  function(doc) {
     if (doc._id=="321"){
          // How do get another document like in python, for example
          var doc2 = db[doc.owner_id];
          if (doc2.public) {
             emit(doc._id, null);
         }
     }
  }
  </code></pre>