Skip to content

Unable to aggregate subdocuments #28

Closed
@andrewryno

Description

@andrewryno

I'm having a problem where I can't aggregate subdocuments. The problem is that my $columns argument has columns like subdocument.key. Mongo doesn't like that and spits out this error:

exception: the group aggregate field name 'metrics.clicks' cannot be used because $group's field names cannot contain '.'

Dump of the $group pipeline looks like this:

array(2) [
    '_id' => integer 0
    'metrics.clicks' => array(1) [
        '$sum' => string (15) "$metrics.clicks"
    ]
]

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions