Skip to content
Discussion options

You must be logged in to vote

You’re getting the error because the method name is misspelled. It should be aggregate(), not aggregrate(). Also, aggregate() accepts a single pipeline array.

Here is the corrected controller code:

return ReportOutput::raw(function ($collection) use ($siteId) {
    return $collection->aggregate([
        [
            '$match' => [
                'site_id' => $siteId
            ]
        ],
        [
            '$lookup' => [
                'from' => 'websites',
                'localField' => 'site_id',
                'foreignField' => '_id',
                'as' => 'info'
            ]
        ]
    ])->toArray();
});

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by GromNaN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants