title: How should I use CouchDBs views in Flask proper
body: <p>I'm using Flask and CouchDB. I've mapped a file document to a file object.</p>
  
  <pre><code>class File(Document):
     name = TextField()
     conten = TextField()
  </code></pre>
  
  <p>In my Flask Blueprint I want to return all files. How do I do that. I know that I've to write a view like:</p>
  
  <pre><code>function(doc) {
     if(doc.type == 'file') {
        emit(doc_id, doc)
     }
  }
  </code></pre>
  
  <p>But where do I've to put this piece of code? In my <code>File</code> object? Do I've to add this view definition to the <code>CouchDBManager</code>? Or should I use the <a href="http://pythonhosted.org/Flask-CouchDB/#flaskext.couchdb.Document.query" rel="nofollow">query</a> function?</p>