martenframework / marten

The pragmatic web framework.
https://martenframework.com
MIT License
407 stars 23 forks source link

Add the ability to sum the values of a given column in query sets #96

Closed ellmetha closed 7 months ago

ellmetha commented 1 year ago

Description

There is presently no easy way to sum the values of a given column - at the database level - by leveraging query sets. In order to palliate this, let's add a new #sum method to the base query set implementation. This new method should take the name of a field for which the sum should be computed.

For example:

Person.all.sum(:age) # => 1234