ichikaway/cakephp-mongodb — pull request #74 by codingthoughts (2013-04-30 14:35:10+00:00)
Title: Added support for MongoDB aggregation framework to the datasource

Now, we can pass something like:

$conditions = array(
'aggregate' => array(
array(
'$match' => array(
'refNo' => 1,
'date' => array(
'$gte' => '2013-03-30',
'$lte' => '2013-04-30'
)
)
),
array(
'$group' => array(
'_id' => '$product',
'count' => array(
'$sum' => '$count'
)
)
),
array(
'$project' => array(
'product' => '$_id',
'count' => 1
)
)
)
)

to the paginate or find method. It is the same array as you would pass to the MongoDB aggregate method for the PHP driver.

Fully works with pagination.