Count unique records with DataMapper

Saturday 01/3/2009  –  Category: Uncategorized

dm-aggregates provides an aggregate method that allows for "multiple aggregate functions to be used in a single query, with automatic grouping when :fields is specified"

Hit.aggregate(:ip_address).length

Will yield the number of unique IP addresses in the hits table.

Leave a Reply