RethinkDB: Sum example

In RethinkDB, you can do a ‘sum’ and a GROUP BY like so:

r.db('test')
 .table('salaries')
 .group('role')
 .sum('salary')
 .ungroup()
 .map({Title: r.row('group'), Salary: r.row('reduction')})

If you just want an overall sum, do this:

r.db('test')
 .table('salaries')
 .sum('salary')
Salary
Title
1
403000
null
2
217000
Designer
3
425000
Manager