public
Description: Extras for DataMapper, including bridges to DataObjects::Migrations and Merb::DataMapper
Homepage: http://datamapper.org
Clone URL: git://github.com/sam/dm-more.git
Dan Kubb (author)
Tue Jul 15 12:37:10 -0700 2008
commit  06a9599d5ed86b70441ce9fc15cc296470b42a93
tree    ee05ee97d681ab2ecdf55e22046114ce03c8b083
parent  c366fee263c578c2363b2242d61b935d8b556094
dm-more / dm-aggregates
name age message
..
file LICENSE Sat May 03 07:01:02 -0700 2008 Create dm-aggregates (only has count method for... [foysavas]
file README Wed Jul 16 08:42:00 -0700 2008 Hoe-ification for dm-adjust, dm-aggregates, dm-... [bernerdschaefer]
file Rakefile Loading commit data...
file TODO Sat Jun 14 15:23:57 -0700 2008 adding dm-adjust to be able to increment and de... [Sindre Aarsaether]
directory lib/
directory spec/
dm-aggregates/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.max(:age, :conditions => [ 'gender = ?', 'female' ]) # returns the total age of all female friends