I think that's the groupedMapReduce you are looking for:
r.db('songs').table('votes').groupedMapReduce(
function(vote) { return vote('song_id')},
function(vote) { return r.branch(
vote("vote").eq("like"),
{like: 1, dislike: 0},
{like: 0, dislike: 1}
)},
function(left, right) {
return {
like: left("like").add(right("like")),
dislike: left("dislike").add(right("dislike"))
}
}
)
Also RethinkDB next version (schedule in 1-2 weeks) is going to replace groupedMapReduce
with a better group
command.