Skip to content

Instantly share code, notes, and snippets.

@Enome
Created April 23, 2012 10:20
Show Gist options
  • Save Enome/2470115 to your computer and use it in GitHub Desktop.
Save Enome/2470115 to your computer and use it in GitHub Desktop.
balance:
map: (doc)->
if doc.type is 'transaction'
emit( doc.relatedId, doc.amount )
reduce: (keys, values, rereduce)->
total = 0.0
for value in values
total += parseFloat value
return total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment