What is the Python syntax for adding the reduce part of a map/reduce pair in the ViewDefinition method of couchdb? -


i add permanent view couchdb database using viewdefinition class in python rather use futon define view.

i have added map part of map/reduce pair so:

postbyid = viewdefinition(‘application’,‘postbyid’, ‘function(doc) {if (doc.type==”posts”) {emit(doc.id, doc)};}’)  postbyid.sync(database) 

but cannot work out syntax adding reduce part of map/reduce pair.

for instance, if intended view looks (copied futon):

"views": {    "postbyid": {        "map": "function(doc) {\n\tif (doc.type==\"post\") {\n  emit(doc.id, doc)};\n}",        "reduce": "_count" 

how code reduce part of map/reduce pair in viewdefinition class?

alternatively, on right track or there better way of doing this?

the reduce function entered fourth parameter. found looking through couchdb library code documentation , examples little sparse.

postbyid = viewdefinition(‘application’,‘postbyid’, ‘function(doc) {if (doc.type==”posts”) {emit(doc.id, doc)};}’ , '_count') 

hope helps else.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -