Created
May 15, 2015 12:31
-
-
Save codinfox/50f1e61c842f3e4091ca to your computer and use it in GitHub Desktop.
ErrorBoard使用RethinkDB查询聚合
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
r.db('ErrorTracker').table('logs').group('message').map(function(doc){ | |
return { | |
count: 1, | |
from: doc('timestamp'), | |
to: doc('timestamp'), | |
browsers: r([doc('ua')('family')]) | |
} | |
}).reduce(function(left, right){ | |
return { | |
count: left('count').add(right('count')), | |
from: r.branch(left('from').lt(right('from')), left('from'), right('from')), | |
to: r.branch(left('to').gt(right('to')), left('to'), right('to')), | |
browsers: left('browsers').setUnion(right('browsers')) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment