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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -