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
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 (:
2 Comments
vkefallinos
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?