-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Unable to aggregate subdocuments #28
Comments
Can you use a "project" before the group to project $metric.clicks to something without a '.' in it? In my case, I have a "Order" document with an array of "Line" documents...I called
|
I'm really trying to avoid having to use a raw query, simply because I just moved away from the default PHP driver for that reason. :P So I was able to get this working. When you use the aggregate functions, it's completely unnecessary for the highest level key (in this case I can provide a patch/tests if anyone wants. It doesn't change the output at all. I get my aggregations perfectly. :) |
I'd like to see how you did the aggregations without a raw query...I couldn't figure out what the format was for subdocuments, so I switched to raw. |
What would be the best solution; replace metrics.clicks with 'metrics_clicks', or just 'clicks'? |
Probably underscore, although it really doesn't matter since that key isn't used anywhere else, since the aggregate() function itself uses I'm working on a pull request right now. |
Sweet! |
Done in #29. |
I'm having a problem where I can't aggregate subdocuments. The problem is that my
$columns
argument has columns likesubdocument.key
. Mongo doesn't like that and spits out this error:Dump of the
$group
pipeline looks like this:I'm not sure if this is even possible to fix without deviating too much from the Laravel query builder. Could possibly add a third optional parameter to rename columns, but I don't know if that would be wise.
Possibly introduce some set of characters to denote spaces, pass that to Mongo, and then split by those characters when Mongo comes back with the aggregates?
The text was updated successfully, but these errors were encountered: