Permalink
Browse files

updated dm-aggregates/README and README

  • Loading branch information...
Abdul-Rahman Advany authored and myabc committed May 19, 2008
1 parent 660e584 commit 53272c2878ce43aecbd67f0c7c058c7832ee48aa
Showing with 47 additions and 2 deletions.
  1. +5 −0 README
  2. +42 −2 dm-aggregates/README
View
5 README
@@ -7,3 +7,8 @@ Including:
* Migrations
* Validations
+ * Aggregates
+
+== Aggregates
+
+Currently includes count, min, max, avg, sum (more info in dm-aggregates/README)
View
@@ -1,5 +1,45 @@
dm-aggregates
=============
-DataMapper plugin providing support for aggregates, functions on collections and
-datasets.
+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 a address (NULL values are not included)
+ Friend.count(:address, :age.gt => 18) # returns count of all friends with a address that are older then 18
+ Friend.count(:adress, :conditions => [ 'gender = ?', 'female' ]) # returns count of all your female friends with a 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

0 comments on commit 53272c2

Please sign in to comment.