Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for MongoDB aggregation framework to the datasource #74

Open
wants to merge 2 commits into
base: cake2.2
Choose a base branch
from

Conversation

codingthoughts
Copy link

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.

@k1LoW
Copy link
Contributor

k1LoW commented May 1, 2013

If you can, add testcase, because I do not know what is correct.

@codingthoughts
Copy link
Author

Sure, i will add test cases and commit them soon.

@k1LoW
Copy link
Contributor

k1LoW commented May 1, 2013

Thank you !

@codingthoughts
Copy link
Author

Hi, I have added test cases.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 0303bac on codingthoughts:cake2.2 into * on ichikaway:cake2.2*.

@k1LoW
Copy link
Contributor

k1LoW commented May 2, 2013

Unfortunately, testcase failed in Travis CI. (maybe mongo version)

check following url
https://travis-ci.org/ichikaway/cakephp-mongodb/builds/6792448

@codingthoughts
Copy link
Author

Hi, I looked at it. The case is failing in PECL Mongo 1.2.9 driver which is almost a year old and it did not have the support for aggregation framework. All the newer versions support aggregation.Aggregation requires version greater than 1.3.0.

Checkout:
http://pecl.php.net/package/mongo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants