Skip to content

$pipeline is not a list (unexpected index: "$group") #1030

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

Closed
mutaharte opened this issue Nov 9, 2016 · 1 comment
Closed

$pipeline is not a list (unexpected index: "$group") #1030

mutaharte opened this issue Nov 9, 2016 · 1 comment

Comments

@mutaharte
Copy link

mutaharte commented Nov 9, 2016

I am getting this error when I try to use group and count.

ERROR:

InvalidArgumentException in Aggregate.php line 93:
$pipeline is not a list (unexpected index: "$group")

MongoDB version: 3.2.9
jenssegers/mongodb version : 3.1.0-alpha

Here is my code.

$analytics = DB::collection('analytics')->raw( function ( $collection ) {
            return $collection->aggregate([
                '$group' => [
                    '_id'    => [ 'campaign_id' => '$campaign_id', 'type' => '$type' ],
                    'count'  => ['$sum' => 1],
                ]
            ]);
        });

I've also tried this code (enclosing aggregate in array) following solution form this issue. #880

$analytics = DB::collection('analytics')->raw( function ( $collection ) {
            return $collection->aggregate([
                [
                    '$group' => [
                        '_id'    => [ 'campaign_id' => '$campaign_id', 'type' => '$type' ],
                        'count'  => ['$sum' => 1],
                    ]
                ],
            ]);
        });

but this time error is

UnexpectedValueException in compiled.php line 16079:
The Response content must be a string or object implementing __toString(), "object" given.

@mutaharte
Copy link
Author

mutaharte commented Nov 14, 2016

ISSUE FIXED
#880 solution worked.

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

No branches or pull requests

1 participant