title: CouchDB and validate_doc_read function
body: <h3>The problem:</h3>
  
  <p>CouchDB has not be designed to support per-document read-control.</p>
  
  <h3>As a proposed solution:</h3>
  
  <p>Create <strong>Validate_doc_read</strong> function (javascript function be called on every read, in the same manner as the validate_doc_update system is applied). </p>
  
  <p>In <strong>_users database</strong> I defined function inside the document like this:</p>
  
  <pre><code>"validate_doc_read": "function(doc, userCtx) {
      if ((typeof doc.name !== 'undefined') &amp;&amp; (doc.name != userCtx.name)) {
          throw({unauthorized: userCtx.name + ' cannnot read ' + doc._id});
      }"
  }
  </code></pre>
  
  <p>But the function does not work Why?</p>