Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Wrapper Decorator for Reduce function #323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

twheys
Copy link

@twheys twheys commented Jul 16, 2017

Fixes #105

Added a mutator function for the ViewField decorator which allows a reduce function to be set on a ViewField using a second decorator. This is just some sugar for creation a view with a map and reduce function using an explicit syntax.

Example

class Item(Document):
     sku = TextField()
     color = IntegerField()

     stock = ViewField('people')

     @stock.map
     def map(doc):
         yield doc['sku'], doc

     @stock.reduce
     def reduce(keys, values, rereduce):
         if rereduce:
             yield sum(values)
         else:
             yield len(values)

…ich allows a reduce function to be set on a ViewField using a second decorator.
@twheys twheys force-pushed the feature/100_reduce_decorator branch from 7dfad08 to 91b61d4 Compare July 16, 2017 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant