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

Support _id aggregation operators for $group stage #3096

Merged
merged 19 commits into from
Jul 26, 2023
Prev Previous commit
Next Next commit
wip
  • Loading branch information
noisersup committed Jul 25, 2023
commit f9011b112ce073dd3ace8870c285d87828bcca27
16 changes: 13 additions & 3 deletions internal/handlers/common/aggregations/stages/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,25 @@ func newGroup(stage *types.Document) (aggregations.Stage, error) {

if field == "_id" {
if doc, ok := v.(*types.Document); ok {
if operators.IsOperator(doc) {
if !operators.IsOperator(doc) {
if err = validateExpression("$group", doc); err != nil {
return nil, err
}

groupKey = v
continue
}

if err = validateExpression("$group", doc); err != nil {
return nil, err
op, err := operators.NewOperator(doc)
if err != nil {
return nil, processOperatorError(err)
}

if _, err := op.Process(nil); err != nil {
return nil, processOperatorError(err)
}
}

groupKey = v
continue
}
Expand Down