Error: Parse Objects not allowed here
Asked Answered
R

2

7

When I try to run count function I get

Error: Parse Objects not allowed here

E2015-11-09T12:36:10.778Z]v184 Ran cloud function count with:
  Input: {}
  Result: Error: Parse Objects not allowed here
    at n (Parse.js:16:1063)
    at Parse.js:16:1927
    at Array.map (native)
    at n (Parse.js:16:1904)
    at n (Parse.js:16:1995)
    at r.default (Parse.js:16:2422)
    at Object.o.default.setCloudController.run (Parse.js:13:2159)
    at Object.n [as run] (Parse.js:13:1730)
    at e.query.find.success (main.js:10:19)
    at e.<anonymous> (Parse.js:14:28224)

The searching result guide me to this question, But All the tutorials mention sending parameters in this way. And this code used to be functioning well.

Count Function :

Parse.Cloud.define('count', function(request, response) {

var query = new Parse.Query('MyS');
  query.equalTo("Notify", true);
  query.notEqualTo ("MainEventCode", '5');

  query.find({
    success: function(results) {
      Parse.Cloud.run('http', {params : results}).then(
        function(result) {
          console.log('httpResponse is : ' + result);
          response.success('Done !');
        }, function(error) {
          console.log('Error while RUN !' + error);
      });
    },
    error: function(error) {
      response.error(error);
    }
  });
});

http Function :

Parse.Cloud.define('http', function(request, response) {

var query = new Parse.Query(Parse.Installation);
.
.
.
}
Ramonaramonda answered 9/11, 2015 at 13:30 Comment(0)
L
7

I'm assuming results is an array of PFObjects. Unfortunately you can not send PFObjects or an array containing PFObjects as parameters. Instead you'll need to send an array of their object Ids, and retrieve the actual objects in your http function.

Lateshalatest answered 10/11, 2015 at 12:16 Comment(0)
C
1

I recomend pass the object id to the function. Then in the cloud function:

var Movie = Parse.Object.extend("MovieClass");

Parse.Cloud.define("averageStars", async (request) => {

  //Creating the ParseObject
  var pointer = Movie.createWithoutData(request.params.obj_id);

  //Creating a query
  const query = new Parse.Query("ReviewClass");
  query.equalTo("field_pointer_movie",pointer);

  const results = await query.find();
  let sum = 0;
  for (let i = 0; i < results.length; ++i) {
    sum += results[i].get("stars");
  }
  return sum / results.length;
});

This doc help me out

Cloutman answered 27/7, 2020 at 13:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.