Skip to content Skip to sidebar Skip to footer

Merging Object's Attribute In Rereduce Function Resulted In Wrong Value Each Time The View Is Created

This is follow up from this question How to merge objects attributes from reduce to rereduce function in CouchDB I've been following the accepted answer from the previous question.

Solution 1:

You're relying on adjacent records being present. You can't predict how Couch will split the set of values it passes to your reduce function. You will absolutely get called with the split happening betweentitle and salary records for the same employee. Meaning that in a given invocation of your reduce function you will have a title but not the salary, or vice versa.

I don't think there's any way to do what you're trying to with your current data structure. You should do the average calculations on the client side, or change your document structure so that it stores both the salary and the title in the same document (the latter would be my approach).

Post a Comment for "Merging Object's Attribute In Rereduce Function Resulted In Wrong Value Each Time The View Is Created"