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);
.
.
.
}
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With