Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ ___
- EXPERIMENTAL: Added custom routes to easily customize flows for password reset, email verification or build entirely new flows (Manuel Trezza) [#7231](https://github.com/parse-community/parse-server/issues/7231)
- Added Deprecation Policy to govern the introduction of braking changes in a phased pattern that is more predictable for developers (Manuel Trezza) [#7199](https://github.com/parse-community/parse-server/pull/7199)
### Other Changes
- Support aggregation stage names starting with '$' just like in MongoDB (Raschid JF Rafeally) [#7339](https://github.com/parse-community/parse-server/pull/7339)
- Fix error when a not yet inserted job is updated (Antonio Davi Macedo Coelho de Castro) [#7196](https://github.com/parse-community/parse-server/pull/7196)
- request.context for afterFind triggers (dblythy) [#7078](https://github.com/parse-community/parse-server/pull/7078)
- Winston Logger interpolating stdout to console (dplewis) [#7114](https://github.com/parse-community/parse-server/pull/7114)
Expand Down
18 changes: 18 additions & 0 deletions spec/AggregateRouter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,22 @@ describe('AggregateRouter', () => {
const result = AggregateRouter.getPipeline(body);
expect(result).toEqual(expected);
});

it("support stage name starting with '$'", () => {
const body = {
$match: { someKey: 'whatever' },
};
const expected = [{ $match: { someKey: 'whatever' } }];
const result = AggregateRouter.getPipeline(body);
expect(result).toEqual(expected);
});

it("support stage name not starting with '$'", () => {
const body = {
match: { someKey: 'whatever' },
};
const expected = [{ $match: { someKey: 'whatever' } }];
const result = AggregateRouter.getPipeline(body);
expect(result).toEqual(expected);
});
});
3 changes: 2 additions & 1 deletion src/Routers/AggregateRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ export class AggregateRouter extends ClassesRouter {
stage[stageName]._id = stage[stageName].objectId;
delete stage[stageName].objectId;
}
return { [`$${stageName}`]: stage[stageName] };
const key = stageName[0] === '$' ? stageName : `$${stageName}`;
return { [key]: stage[stageName] };
}

mountRoutes() {
Expand Down