1

I know i can use couchdb.ViewDefinition to create a view for a database.Is there something similar to create a changes filter function or I can just create a design document with the filters field?

1 Answer 1

2

Currently there is no such what unless you'll operate with design documents as regular onces e.g. dumping python function to source code and assigning it to ddoc filters field.

You may try to apply patch from issue 186: it provides support of definition show/list/update/filter/validate_doc_update functions in manner like views currently does.

For instance:

from couchdb import design, mapping

class Post(mapping.Document):

   by_author = design.FilterFunction('posts', 'by_name', '''
function(doc, req){
  if (req.query.author){
    return doc.author === req.query.author;
  }
  throw({'invalid_query': 'author name was not specified'});
}
''')

if __name__ == '__main__:
    design.sync_docs(db, [Post])

Feedback and bugs are welcomed (:

Sign up to request clarification or add additional context in comments.

2 Comments

I am using couchdb on a production server.Do you think it is stable enough to use it or should I use the regular way of creating documents?
Not sure so I'd like to suggest you test it first before applying in production environment. For stable solution better to work with ddocs as with regular docs or even switch to couchapp or erica tool for working with ddocs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.