Skip to content

Aggregate allow multiple of same stage #4835

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

Merged
merged 5 commits into from
Jun 23, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion spec/ParseQuery.Aggregate.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ describe('Parse.Query Aggregate testing', () => {
});
});

it_exclude_dbs(['postgres'])('aggregate allow multiple stages', (done) => {
it_exclude_dbs(['postgres'])('aggregate allow multiple of same stage', (done) => {
const pointer1 = new TestObject({ value: 1});
const pointer2 = new TestObject({ value: 2});
const pointer3 = new TestObject({ value: 3});
Expand Down
8 changes: 5 additions & 3 deletions src/Routers/AggregateRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import * as middleware from '../middlewares';
import Parse from 'parse/node';
import UsersRouter from './UsersRouter';

const ALLOWED_KEYS = [
'where',
'distinct',
const BASE_KEYS = ['where', 'distinct'];

const PIPELINE_KEYS = [
'addFields',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make a list of PIPELINE_KEYS and BASE_KEYS and concat them in ALLOWED_KEYS for readability?

'bucket',
'bucketAuto',
Expand Down Expand Up @@ -34,6 +34,8 @@ const ALLOWED_KEYS = [
'unwind',
];

const ALLOWED_KEYS = BASE_KEYS.concat(PIPELINE_KEYS);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will mutate BASE_KEYS IIRC :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concat docs say it doesn’t mutate

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok my bad, getting a bit rusty :p spread is quite nice :)


export class AggregateRouter extends ClassesRouter {

handleFind(req) {
Expand Down