From 931e31b8781e0b2d775d43c78174a2cde93e7e2a Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Wed, 13 Jun 2018 20:45:52 -0500 Subject: [PATCH 1/4] Aggregate Allow Multiple Stages --- run-js-server | 84 +++++++++++++++++++++++++++ run-php-server | 86 ++++++++++++++++++++++++++++ run-server | 85 ++++++++++++++++++++++++++++ spec/ParseQuery.Aggregate.spec.js | 43 ++++++++++++++ src/Routers/AggregateRouter.js | 94 +++++++++++++++++++------------ 5 files changed, 355 insertions(+), 37 deletions(-) create mode 100755 run-js-server create mode 100755 run-php-server create mode 100755 run-server diff --git a/run-js-server b/run-js-server new file mode 100755 index 0000000000..42cc34c454 --- /dev/null +++ b/run-js-server @@ -0,0 +1,84 @@ +#!/usr/bin/env bash +# +# Setups parse-server, in an easy fashion +# Used for running Test Cases against the parse-php-sdk +# + +############ +## Config ## +############ + +# app name +APP_NAME="MyTestApp" + +# application id +#APP_ID="MK5KVBqIzhhM5tIwX9hrKnQLLKpHeJ9O0VHS4Fqp" +#APP_ID="test" +APP_ID="integration" +#APP_ID="app-id-here" + +# master key +#MASTER_KEY="G1QPMwxoMOfCNALvY7RrQkk9Z2X2yin7kQkemghg" +#MASTER_KEY="test" +MASTER_KEY="notsosecret" +#MASTER_KEY="master-key-here" + +# rest key +#REST_KEY="" +#REST_KEY="rest-api-key-here" + +# mongodb database uri +# DATABASE_URI="postgres://localhost:5432/parse_server_postgres_adapter_test_database" +#PARSE_SERVER_TEST_DB=postgres PARSE_SERVER_LOG_LEVEL=debug npm test spec/ParseQuery.spec.js +#PARSE_SERVER_TEST_DB=postgres npm test spec/ParseQuery.spec.js +DATABASE_URI="mongodb://localhost:27017/integration" +#DATABASE_URI="mongodb://localhost:27017/integration" + +# location of cloud code file (this location) +CLOUD_CODE_FILE="`pwd`/cloud-code.js" + +# parse push configuration (mock and android only) +PUSH_CONFIG='{"android":{"senderId":"blank-sender-id","apiKey":"not-a-real-api-key"}}' + +# email adapter configuration, default is mailgun with nonfunctional keys +EMAIL_ADAPTER_CONFIG='{"module":"parse-server-simple-mailgun-adapter","options":{"apiKey":"not-a-real-api-key","domain":"example.com","fromAddress":"example@example.com"}}' + +# parse server publicly accessible url +PUBLIC_URL="http://localhost:1337/parse" + +# auth data +AUTH_DATA='{"twitter":{"consumer_key":"not_a_real_consumer_key","consumer_secret":"not_a_real_consumer_secret"},"facebook":{"appIds":"not_a_real_facebook_app_id"}}' + +CLASS_NAME='TestObject,User,_User'; + + +# Start MongoDB + +# space out commands from mongodb-runner +echo " +" + +# Start ParseServer from the command line, note we are using cloud code as well +TESTING=1 npm run start -- \ + --appName $APP_NAME\ + --appId $APP_ID\ + --masterKey $MASTER_KEY\ + --restAPIKey $REST_KEY\ + --databaseURI $DATABASE_URI\ + --push $PUSH_CONFIG\ + --emailAdapter $EMAIL_ADAPTER_CONFIG\ + --publicServerURL $PUBLIC_URL\ + --auth $AUTH_DATA\ + --verbose\ + +echo " +...shutting down... +" + +# Stop MongoDB + +echo " +Done! +" + +exit 0 \ No newline at end of file diff --git a/run-php-server b/run-php-server new file mode 100755 index 0000000000..37ecf99832 --- /dev/null +++ b/run-php-server @@ -0,0 +1,86 @@ +#!/usr/bin/env bash +# +# Setups parse-server, in an easy fashion +# Used for running Test Cases against the parse-php-sdk +# + +############ +## Config ## +############ + +# app name +APP_NAME="MyTestApp" + +# application id +#APP_ID="MK5KVBqIzhhM5tIwX9hrKnQLLKpHeJ9O0VHS4Fqp" +#APP_ID="test" +#APP_ID="integration" +APP_ID="app-id-here" + +# master key +#MASTER_KEY="G1QPMwxoMOfCNALvY7RrQkk9Z2X2yin7kQkemghg" +#MASTER_KEY="test" +#MASTER_KEY="notsosecret" +MASTER_KEY="master-key-here" + +# rest key +#REST_KEY="" +#REST_KEY="rest" +REST_KEY="rest-api-key-here" + +# mongodb database uri +# DATABASE_URI="postgres://localhost:5432/parse_server_postgres_adapter_test_database" +#PARSE_SERVER_TEST_DB=postgres PARSE_SERVER_LOG_LEVEL=debug npm test spec/ParseQuery.spec.js +#PARSE_SERVER_TEST_DB=postgres npm test spec/ParseQuery.spec.js +DATABASE_URI="mongodb://localhost:27017/parseServerMongoAdapterTestDatabase" +#DATABASE_URI="mongodb://localhost:27017/integration" + +# location of cloud code file (this location) +CLOUD_CODE_FILE="`pwd`/cloud-code.js" + +# parse push configuration (mock and android only) +PUSH_CONFIG='{"android":{"senderId":"blank-sender-id","apiKey":"not-a-real-api-key"}}' + +# email adapter configuration, default is mailgun with nonfunctional keys +EMAIL_ADAPTER_CONFIG='{"module":"parse-server-simple-mailgun-adapter","options":{"apiKey":"not-a-real-api-key","domain":"example.com","fromAddress":"example@example.com"}}' + +# parse server publicly accessible url +PUBLIC_URL="http://localhost:1337/parse" + +# auth data +AUTH_DATA='{"twitter":{"consumer_key":"not_a_real_consumer_key","consumer_secret":"not_a_real_consumer_secret"},"facebook":{"appIds":"not_a_real_facebook_app_id"}}' + +CLASS_NAME='TestObject,User,_User'; + + +# Start MongoDB + +# space out commands from mongodb-runner +echo " +" + +# Start ParseServer from the command line, note we are using cloud code as well +npm run start -- \ + --appName $APP_NAME\ + --appId $APP_ID\ + --masterKey $MASTER_KEY\ + --restAPIKey $REST_KEY\ + --databaseURI $DATABASE_URI\ + --push $PUSH_CONFIG\ + --emailAdapter $EMAIL_ADAPTER_CONFIG\ + --publicServerURL $PUBLIC_URL\ + --auth $AUTH_DATA\ + --startLiveQueryServer true\ + --verbose\ + +echo " +...shutting down... +" + +# Stop MongoDB + +echo " +Done! +" + +exit 0 \ No newline at end of file diff --git a/run-server b/run-server new file mode 100755 index 0000000000..7ee2ed8cf0 --- /dev/null +++ b/run-server @@ -0,0 +1,85 @@ +#!/usr/bin/env bash +# +# Setups parse-server, in an easy fashion +# Used for running Test Cases against the parse-php-sdk +# + +############ +## Config ## +############ + +# app name +APP_NAME="MyTestApp" + +# application id +APP_ID="MK5KVBqIzhhM5tIwX9hrKnQLLKpHeJ9O0VHS4Fqp" +#APP_ID="test" +#APP_ID="integration" +#APP_ID="app-id-here" + +# master key +MASTER_KEY="G1QPMwxoMOfCNALvY7RrQkk9Z2X2yin7kQkemghg" +#MASTER_KEY="test" +#MASTER_KEY="notsosecret" +#MASTER_KEY="master-key-here" + +# rest key +REST_KEY="VIcqjZWIKDJPsNh4JjqQaCFkFzxH10bjVyaUXKi7" +#REST_KEY="rest" +#REST_KEY="rest-api-key-here" + +# mongodb database uri +# DATABASE_URI="postgres://localhost:5432/parse_server_postgres_adapter_test_database" +#PARSE_SERVER_TEST_DB=postgres PARSE_SERVER_LOG_LEVEL=debug npm test spec/ParseQuery.spec.js +#PARSE_SERVER_TEST_DB=postgres npm test spec/ParseQuery.spec.js +DATABASE_URI="mongodb://localhost:27017/parseServerMongoAdapterTestDatabase" +#DATABASE_URI="mongodb://localhost:27017/integration" + +# location of cloud code file (this location) +CLOUD_CODE_FILE="`pwd`/cloud-code.js" + +# parse push configuration (mock and android only) +PUSH_CONFIG='{"android":{"senderId":"blank-sender-id","apiKey":"not-a-real-api-key"}}' + +# email adapter configuration, default is mailgun with nonfunctional keys +EMAIL_ADAPTER_CONFIG='{"module":"parse-server-simple-mailgun-adapter","options":{"apiKey":"not-a-real-api-key","domain":"example.com","fromAddress":"example@example.com"}}' + +# parse server publicly accessible url +PUBLIC_URL="http://localhost:1337/parse" + +# auth data +AUTH_DATA='{"twitter":{"consumer_key":"not_a_real_consumer_key","consumer_secret":"not_a_real_consumer_secret"},"facebook":{"appIds":"not_a_real_facebook_app_id"}}' + +CLASS_NAME='TestObject,User,_User'; + + +# Start MongoDB + +# space out commands from mongodb-runner +echo " +" + +# Start ParseServer from the command line, note we are using cloud code as well +npm run start -- \ + --appName $APP_NAME\ + --appId $APP_ID\ + --masterKey $MASTER_KEY\ + --restAPIKey $REST_KEY\ + --databaseURI $DATABASE_URI\ + --push $PUSH_CONFIG\ + --emailAdapter $EMAIL_ADAPTER_CONFIG\ + --publicServerURL $PUBLIC_URL\ + --auth $AUTH_DATA\ + --verbose\ + +echo " +...shutting down... +" + +# Stop MongoDB + +echo " +Done! +" + +exit 0 \ No newline at end of file diff --git a/spec/ParseQuery.Aggregate.spec.js b/spec/ParseQuery.Aggregate.spec.js index c698395085..b346724bf3 100644 --- a/spec/ParseQuery.Aggregate.spec.js +++ b/spec/ParseQuery.Aggregate.spec.js @@ -744,4 +744,47 @@ describe('Parse.Query Aggregate testing', () => { fail(err); }); }); + + it_exclude_dbs(['postgres'])('aggregate allow multiple stages', (done) => { + const pointer1 = new TestObject({ value: 1}); + const pointer2 = new TestObject({ value: 2}); + const pointer3 = new TestObject({ value: 3}); + + const obj1 = new TestObject({ pointer: pointer1, name: 'Hello' }); + const obj2 = new TestObject({ pointer: pointer2, name: 'Hello' }); + const obj3 = new TestObject({ pointer: pointer3, name: 'World' }); + + const options = Object.assign({}, masterKeyOptions, { + body: [{ + match: { name: "Hello" }, + }, { + // Transform className$objectId to objectId and store in new field tempPointer + project: { + tempPointer: { $substr: [ "$_p_pointer", 11, -1 ] }, // Remove TestObject$ + }, + }, { + // Left Join, replace objectId stored in tempPointer with an actual object + lookup: { + from: "test_TestObject", + localField: "tempPointer", + foreignField: "_id", + as: "tempPointer" + }, + }, { + // lookup returns an array, Deconstructs an array field to objects + unwind: { + path: "$tempPointer", + }, + }, { + match : { "tempPointer.value" : 2 }, + }] + }); + Parse.Object.saveAll([pointer1, pointer2, pointer3, obj1, obj2, obj3]).then(() => { + return rp.get(Parse.serverURL + '/aggregate/TestObject', options); + }).then((resp) => { + expect(resp.results.length).toEqual(1); + expect(resp.results[0].tempPointer.value).toEqual(2); + done(); + }); + }); }); diff --git a/src/Routers/AggregateRouter.js b/src/Routers/AggregateRouter.js index 8f4e859b6d..72d2915b17 100644 --- a/src/Routers/AggregateRouter.js +++ b/src/Routers/AggregateRouter.js @@ -7,27 +7,31 @@ import UsersRouter from './UsersRouter'; const ALLOWED_KEYS = [ 'where', 'distinct', - 'project', + 'addFields', + 'bucket', + 'bucketAuto', + 'collStats', + 'count', + 'currentOp', + 'facet', + 'geoNear', + 'graphLookup', + 'group', + 'indexStats', + 'limit', + 'listLocalSessions', + 'listSessions', + 'lookup', 'match', + 'out', + 'project', 'redact', - 'limit', - 'skip', - 'unwind', - 'group', + 'replaceRoot', 'sample', + 'skip', 'sort', - 'geoNear', - 'lookup', - 'out', - 'indexStats', - 'facet', - 'bucket', - 'bucketAuto', 'sortByCount', - 'addFields', - 'replaceRoot', - 'count', - 'graphLookup', + 'unwind', ]; export class AggregateRouter extends ClassesRouter { @@ -35,29 +39,19 @@ export class AggregateRouter extends ClassesRouter { handleFind(req) { const body = Object.assign(req.body, ClassesRouter.JSONFromQuery(req.query)); const options = {}; - const pipeline = []; + let pipeline = []; - for (const key in body) { - if (ALLOWED_KEYS.indexOf(key) === -1) { - throw new Parse.Error(Parse.Error.INVALID_QUERY, `Invalid parameter for query: ${key}`); + if (Array.isArray(body)) { + pipeline = body.map((stage) => { + const stageName = Object.keys(stage)[0]; + return this.transformStage(stageName, stage); + }); + } else { + const stages = []; + for (const stageName in body) { + stages.push(this.transformStage(stageName, body)); } - if (key === 'group') { - if (body[key].hasOwnProperty('_id')) { - throw new Parse.Error( - Parse.Error.INVALID_QUERY, - `Invalid parameter for query: group. Please use objectId instead of _id` - ); - } - if (!body[key].hasOwnProperty('objectId')) { - throw new Parse.Error( - Parse.Error.INVALID_QUERY, - `Invalid parameter for query: group. objectId is required` - ); - } - body[key]._id = body[key].objectId; - delete body[key].objectId; - } - pipeline.push({ [`$${key}`]: body[key] }); + pipeline = stages; } if (body.distinct) { options.distinct = String(body.distinct); @@ -76,6 +70,32 @@ export class AggregateRouter extends ClassesRouter { }); } + transformStage(stageName, stage) { + if (ALLOWED_KEYS.indexOf(stageName) === -1) { + throw new Parse.Error( + Parse.Error.INVALID_QUERY, + `Invalid parameter for query: ${stageName}` + ); + } + if (stageName === 'group') { + if (stage[stageName].hasOwnProperty('_id')) { + throw new Parse.Error( + Parse.Error.INVALID_QUERY, + `Invalid parameter for query: group. Please use objectId instead of _id` + ); + } + if (!stage[stageName].hasOwnProperty('objectId')) { + throw new Parse.Error( + Parse.Error.INVALID_QUERY, + `Invalid parameter for query: group. objectId is required` + ); + } + stage[stageName]._id = stage[stageName].objectId; + delete stage[stageName].objectId; + } + return { [`$${stageName}`]: stage[stageName] }; + } + mountRoutes() { this.route('GET','/aggregate/:className', middleware.promiseEnforceMasterKeyAccess, req => { return this.handleFind(req); }); } From 9d8e620ddd2e31dea084d8a6477adf0b9ae24ca4 Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Wed, 13 Jun 2018 20:47:37 -0500 Subject: [PATCH 2/4] remove testing files --- run-js-server | 84 ------------------------------------------------ run-php-server | 86 -------------------------------------------------- run-server | 85 ------------------------------------------------- 3 files changed, 255 deletions(-) delete mode 100755 run-js-server delete mode 100755 run-php-server delete mode 100755 run-server diff --git a/run-js-server b/run-js-server deleted file mode 100755 index 42cc34c454..0000000000 --- a/run-js-server +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/env bash -# -# Setups parse-server, in an easy fashion -# Used for running Test Cases against the parse-php-sdk -# - -############ -## Config ## -############ - -# app name -APP_NAME="MyTestApp" - -# application id -#APP_ID="MK5KVBqIzhhM5tIwX9hrKnQLLKpHeJ9O0VHS4Fqp" -#APP_ID="test" -APP_ID="integration" -#APP_ID="app-id-here" - -# master key -#MASTER_KEY="G1QPMwxoMOfCNALvY7RrQkk9Z2X2yin7kQkemghg" -#MASTER_KEY="test" -MASTER_KEY="notsosecret" -#MASTER_KEY="master-key-here" - -# rest key -#REST_KEY="" -#REST_KEY="rest-api-key-here" - -# mongodb database uri -# DATABASE_URI="postgres://localhost:5432/parse_server_postgres_adapter_test_database" -#PARSE_SERVER_TEST_DB=postgres PARSE_SERVER_LOG_LEVEL=debug npm test spec/ParseQuery.spec.js -#PARSE_SERVER_TEST_DB=postgres npm test spec/ParseQuery.spec.js -DATABASE_URI="mongodb://localhost:27017/integration" -#DATABASE_URI="mongodb://localhost:27017/integration" - -# location of cloud code file (this location) -CLOUD_CODE_FILE="`pwd`/cloud-code.js" - -# parse push configuration (mock and android only) -PUSH_CONFIG='{"android":{"senderId":"blank-sender-id","apiKey":"not-a-real-api-key"}}' - -# email adapter configuration, default is mailgun with nonfunctional keys -EMAIL_ADAPTER_CONFIG='{"module":"parse-server-simple-mailgun-adapter","options":{"apiKey":"not-a-real-api-key","domain":"example.com","fromAddress":"example@example.com"}}' - -# parse server publicly accessible url -PUBLIC_URL="http://localhost:1337/parse" - -# auth data -AUTH_DATA='{"twitter":{"consumer_key":"not_a_real_consumer_key","consumer_secret":"not_a_real_consumer_secret"},"facebook":{"appIds":"not_a_real_facebook_app_id"}}' - -CLASS_NAME='TestObject,User,_User'; - - -# Start MongoDB - -# space out commands from mongodb-runner -echo " -" - -# Start ParseServer from the command line, note we are using cloud code as well -TESTING=1 npm run start -- \ - --appName $APP_NAME\ - --appId $APP_ID\ - --masterKey $MASTER_KEY\ - --restAPIKey $REST_KEY\ - --databaseURI $DATABASE_URI\ - --push $PUSH_CONFIG\ - --emailAdapter $EMAIL_ADAPTER_CONFIG\ - --publicServerURL $PUBLIC_URL\ - --auth $AUTH_DATA\ - --verbose\ - -echo " -...shutting down... -" - -# Stop MongoDB - -echo " -Done! -" - -exit 0 \ No newline at end of file diff --git a/run-php-server b/run-php-server deleted file mode 100755 index 37ecf99832..0000000000 --- a/run-php-server +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env bash -# -# Setups parse-server, in an easy fashion -# Used for running Test Cases against the parse-php-sdk -# - -############ -## Config ## -############ - -# app name -APP_NAME="MyTestApp" - -# application id -#APP_ID="MK5KVBqIzhhM5tIwX9hrKnQLLKpHeJ9O0VHS4Fqp" -#APP_ID="test" -#APP_ID="integration" -APP_ID="app-id-here" - -# master key -#MASTER_KEY="G1QPMwxoMOfCNALvY7RrQkk9Z2X2yin7kQkemghg" -#MASTER_KEY="test" -#MASTER_KEY="notsosecret" -MASTER_KEY="master-key-here" - -# rest key -#REST_KEY="" -#REST_KEY="rest" -REST_KEY="rest-api-key-here" - -# mongodb database uri -# DATABASE_URI="postgres://localhost:5432/parse_server_postgres_adapter_test_database" -#PARSE_SERVER_TEST_DB=postgres PARSE_SERVER_LOG_LEVEL=debug npm test spec/ParseQuery.spec.js -#PARSE_SERVER_TEST_DB=postgres npm test spec/ParseQuery.spec.js -DATABASE_URI="mongodb://localhost:27017/parseServerMongoAdapterTestDatabase" -#DATABASE_URI="mongodb://localhost:27017/integration" - -# location of cloud code file (this location) -CLOUD_CODE_FILE="`pwd`/cloud-code.js" - -# parse push configuration (mock and android only) -PUSH_CONFIG='{"android":{"senderId":"blank-sender-id","apiKey":"not-a-real-api-key"}}' - -# email adapter configuration, default is mailgun with nonfunctional keys -EMAIL_ADAPTER_CONFIG='{"module":"parse-server-simple-mailgun-adapter","options":{"apiKey":"not-a-real-api-key","domain":"example.com","fromAddress":"example@example.com"}}' - -# parse server publicly accessible url -PUBLIC_URL="http://localhost:1337/parse" - -# auth data -AUTH_DATA='{"twitter":{"consumer_key":"not_a_real_consumer_key","consumer_secret":"not_a_real_consumer_secret"},"facebook":{"appIds":"not_a_real_facebook_app_id"}}' - -CLASS_NAME='TestObject,User,_User'; - - -# Start MongoDB - -# space out commands from mongodb-runner -echo " -" - -# Start ParseServer from the command line, note we are using cloud code as well -npm run start -- \ - --appName $APP_NAME\ - --appId $APP_ID\ - --masterKey $MASTER_KEY\ - --restAPIKey $REST_KEY\ - --databaseURI $DATABASE_URI\ - --push $PUSH_CONFIG\ - --emailAdapter $EMAIL_ADAPTER_CONFIG\ - --publicServerURL $PUBLIC_URL\ - --auth $AUTH_DATA\ - --startLiveQueryServer true\ - --verbose\ - -echo " -...shutting down... -" - -# Stop MongoDB - -echo " -Done! -" - -exit 0 \ No newline at end of file diff --git a/run-server b/run-server deleted file mode 100755 index 7ee2ed8cf0..0000000000 --- a/run-server +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/env bash -# -# Setups parse-server, in an easy fashion -# Used for running Test Cases against the parse-php-sdk -# - -############ -## Config ## -############ - -# app name -APP_NAME="MyTestApp" - -# application id -APP_ID="MK5KVBqIzhhM5tIwX9hrKnQLLKpHeJ9O0VHS4Fqp" -#APP_ID="test" -#APP_ID="integration" -#APP_ID="app-id-here" - -# master key -MASTER_KEY="G1QPMwxoMOfCNALvY7RrQkk9Z2X2yin7kQkemghg" -#MASTER_KEY="test" -#MASTER_KEY="notsosecret" -#MASTER_KEY="master-key-here" - -# rest key -REST_KEY="VIcqjZWIKDJPsNh4JjqQaCFkFzxH10bjVyaUXKi7" -#REST_KEY="rest" -#REST_KEY="rest-api-key-here" - -# mongodb database uri -# DATABASE_URI="postgres://localhost:5432/parse_server_postgres_adapter_test_database" -#PARSE_SERVER_TEST_DB=postgres PARSE_SERVER_LOG_LEVEL=debug npm test spec/ParseQuery.spec.js -#PARSE_SERVER_TEST_DB=postgres npm test spec/ParseQuery.spec.js -DATABASE_URI="mongodb://localhost:27017/parseServerMongoAdapterTestDatabase" -#DATABASE_URI="mongodb://localhost:27017/integration" - -# location of cloud code file (this location) -CLOUD_CODE_FILE="`pwd`/cloud-code.js" - -# parse push configuration (mock and android only) -PUSH_CONFIG='{"android":{"senderId":"blank-sender-id","apiKey":"not-a-real-api-key"}}' - -# email adapter configuration, default is mailgun with nonfunctional keys -EMAIL_ADAPTER_CONFIG='{"module":"parse-server-simple-mailgun-adapter","options":{"apiKey":"not-a-real-api-key","domain":"example.com","fromAddress":"example@example.com"}}' - -# parse server publicly accessible url -PUBLIC_URL="http://localhost:1337/parse" - -# auth data -AUTH_DATA='{"twitter":{"consumer_key":"not_a_real_consumer_key","consumer_secret":"not_a_real_consumer_secret"},"facebook":{"appIds":"not_a_real_facebook_app_id"}}' - -CLASS_NAME='TestObject,User,_User'; - - -# Start MongoDB - -# space out commands from mongodb-runner -echo " -" - -# Start ParseServer from the command line, note we are using cloud code as well -npm run start -- \ - --appName $APP_NAME\ - --appId $APP_ID\ - --masterKey $MASTER_KEY\ - --restAPIKey $REST_KEY\ - --databaseURI $DATABASE_URI\ - --push $PUSH_CONFIG\ - --emailAdapter $EMAIL_ADAPTER_CONFIG\ - --publicServerURL $PUBLIC_URL\ - --auth $AUTH_DATA\ - --verbose\ - -echo " -...shutting down... -" - -# Stop MongoDB - -echo " -Done! -" - -exit 0 \ No newline at end of file From 1200856eb627068d3f29515f8cfb6cfa24f75ffb Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Sat, 23 Jun 2018 09:46:08 -0500 Subject: [PATCH 3/4] nit --- spec/ParseQuery.Aggregate.spec.js | 2 +- src/Routers/AggregateRouter.js | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/spec/ParseQuery.Aggregate.spec.js b/spec/ParseQuery.Aggregate.spec.js index b346724bf3..3668d58969 100644 --- a/spec/ParseQuery.Aggregate.spec.js +++ b/spec/ParseQuery.Aggregate.spec.js @@ -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}); diff --git a/src/Routers/AggregateRouter.js b/src/Routers/AggregateRouter.js index 72d2915b17..f08cefa2bc 100644 --- a/src/Routers/AggregateRouter.js +++ b/src/Routers/AggregateRouter.js @@ -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', 'bucket', 'bucketAuto', @@ -34,6 +34,8 @@ const ALLOWED_KEYS = [ 'unwind', ]; +const ALLOWED_KEYS = BASE_KEYS.concat(PIPELINE_KEYS); + export class AggregateRouter extends ClassesRouter { handleFind(req) { From ef9fdf00b60b7f9e6a2bb7210207bf56fb558d9d Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Sat, 23 Jun 2018 10:50:42 -0500 Subject: [PATCH 4/4] spread them --- src/Routers/AggregateRouter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Routers/AggregateRouter.js b/src/Routers/AggregateRouter.js index f08cefa2bc..c99436f380 100644 --- a/src/Routers/AggregateRouter.js +++ b/src/Routers/AggregateRouter.js @@ -34,7 +34,7 @@ const PIPELINE_KEYS = [ 'unwind', ]; -const ALLOWED_KEYS = BASE_KEYS.concat(PIPELINE_KEYS); +const ALLOWED_KEYS = [...BASE_KEYS, ...PIPELINE_KEYS]; export class AggregateRouter extends ClassesRouter {