0.08
Repository is archived
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
DataMapper plugin providing support for aggregates on collections
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6.4
~> 0.9.2
~> 1.3.2

Runtime

~> 1.2.0
 Project Readme

dm-aggregates

¶ ↑

DataMapper plugin providing support for aggregates, functions on collections and datasets.

It provides the following functions:

count¶ ↑

Count results (given the conditions)

Friend.count # returns count of all friends
Friend.count(:age.gt => 18) # returns count of all friends older then 18
Friend.count(:conditions => [ 'gender = ?', 'female' ]) # returns count of all your female friends
Friend.count(:address) # returns count of all friends with an address (NULL values are not included)
Friend.count(:address, :age.gt => 18) # returns count of all friends with an address that are older then 18
Friend.count(:address, :conditions => [ 'gender = ?', 'female' ]) # returns count of all your female friends with an address

min¶ ↑

Get the lowest value of a property

Friend.min(:age) # returns the age of the youngest friend
Friend.min(:age, :conditions => [ 'gender = ?', 'female' ]) # returns the age of the youngest female friends

max¶ ↑

Get the highest value of a property

Friend.max(:age) # returns the age of the oldest friend
Friend.max(:age, :conditions => [ 'gender = ?', 'female' ]) # returns the age of the oldest female friends

avg¶ ↑

Get the average value of a property

Friend.avg(:age) # returns the average age of friends
Friend.avg(:age, :conditions => [ 'gender = ?', 'female' ]) # returns the average age of the female friends

sum¶ ↑

Get the total value of a property

Friend.sum(:age) # returns total age of all friends
Friend.sum(:age, :conditions => [ 'gender = ?', 'female' ]) # returns the total age of all female friends