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

query.aggregate is not a function in Cloud code #4466

Closed
sauravazad opened this issue Dec 28, 2017 · 2 comments
Closed

query.aggregate is not a function in Cloud code #4466

sauravazad opened this issue Dec 28, 2017 · 2 comments

Comments

@sauravazad
Copy link

query.aggregate is not a function in Cloud code

using query.aggregate in cloud code results in TypeError.

Steps to reproduce

Parse.Cloud.define('aggregateQuery', function(req, res) {
var params = req.params;
var appId = params.appId
var option = {
useMasterKey: true
};
var promiseArray = [];
let pipline = [{$group: {_id :'$source', posts: {$sum : 1}}}];
let mediaquery = new Parse.Query('mediaContent');
mediaquery.aggregate(pipline, option)
.then((s) => {
res.scuccess(s);
}, (e) => {
res.error(s);
})
})

Actual Outcome

error: Error generating response. TypeError: mediaquery.aggregate is not a function

Environment Setup

  • Server

    • parse-server version (Be specific! Don't say 'latest'.) : [2.7.1]
    • Operating System: [OSX 10.13.2]
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): [Localhost]
  • Database

    • MongoDB version: [3.4.7 ]
    • Storage engine: [(MMAPv1)]
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): [Localhost]

Logs/Trace

Include all relevant logs. You can turn on additional logging by configuring VERBOSE=1 in your environment.

verbose: REQUEST for [POST] /parse/functions/aggregateQuery: {} method=POST, url=/parse/functions/aggregateQuery, x-parse-application-id=Quifers_Dev_App_2016, content-type=application/json, x-parse-session-token=r:88524c8138d37f83d33abb0d065ea36f, cache-control=no-cache, postman-token=9777e1ac-437d-4761-83cd-ac1f6b1668f0, user-agent=PostmanRuntime/7.1.1, accept=/, host=localhost:8081, accept-encoding=gzip, deflate, content-length=0, connection=keep-alive,
error: Error generating response. TypeError: mediaquery.aggregate is not a function
at /Users/sauravazad/Documents/WebScript/parse-server/cloud/aggregateQuery.js:11:14
at /Users/sauravazad/Documents/WebScript/parse-server/node_modules/parse-server/lib/Routers/FunctionsRouter.js:176:9
at handleCloudFunction (/Users/sauravazad/Documents/WebScript/parse-server/node_modules/parse-server/lib/Routers/FunctionsRouter.js:144:14)
at /Users/sauravazad/Documents/WebScript/parse-server/node_modules/parse-server/lib/PromiseRouter.js:169:7
at Layer.handle [as handle_request] (/Users/sauravazad/Documents/WebScript/parse-server/node_modules/parse-server/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/sauravazad/Documents/WebScript/parse-server/node_modules/parse-server/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/Users/sauravazad/Documents/WebScript/parse-server/node_modules/parse-server/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/Users/sauravazad/Documents/WebScript/parse-server/node_modules/parse-server/node_modules/express/lib/router/layer.js:95:5)
at /Users/sauravazad/Documents/WebScript/parse-server/node_modules/parse-server/node_modules/express/lib/router/index.js:281:22
at param (/Users/sauravazad/Documents/WebScript/parse-server/node_modules/parse-server/node_modules/express/lib/router/index.js:354:14)

@sauravazad
Copy link
Author

Parse-server @2.7.1 has incorrect version 1.10.2 for parse peer dependency .
Please release a new version with latest version of parse@1.11.0 @flovilmart

@dplewis
Copy link
Member

dplewis commented Dec 28, 2017

@sauravazad You can use the latest branch until the next release if you want to test aggregates.

https://github.com/parse-community/parse-server#want-to-ride-the-bleeding-edge

Also, your pipeline would be written like...

const pipeline = [
  { group: { objectId: '$source', posts: { $sum : 1 } } }
];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants