Skip to content

Instantly share code, notes, and snippets.

@baio
Created June 2, 2012 08:51
Show Gist options
  • Save baio/2857390 to your computer and use it in GitHub Desktop.
Save baio/2857390 to your computer and use it in GitHub Desktop.
min, max date in group
#mongo dev/node/tourism/Parsers/_intel/group.js
print "go..."
grps = db.tour.group
key:
dom : true
country : true
initial:
cnt: 0
min : ''
max : ''
reduce: (doc, out) ->
if !out.min or out.min > doc.checkin then out.min = doc.checkin
if !out.max or out.max < doc.checkin then out.max = doc.checkin
out.cnt++
printjson g for g in grps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment