On our website I want people to be able to report if a video is uploaded on Youtube so we have 3 fields on our website. A Username, password and video Id field. When the user clicks the Html button we have it call a javascript function.
function reportUpload() {
Parse.Cloud.run('report_upload',
{
username: "testUser",
password: "testPassword",
videoId: "VQv9xfOfLOY"
},{
success: function(result) {
//Do Neat Stuff
},
error: function(e) {
//error
}
});
}
That then calls our cloud code function. We need the cloud code function to pull the usernames from the User class and test if any of them match. If any do match they will then need to check if the passwords match. if all of that doesn't fail it will send a push notification to one of the users of the app.
So far in the cloud code funtion I have figured out how to query all the usernames.
Parse.Cloud.define("report_upload", function(request, response) {
console.log(request.params);
var query = new Parse.Query(Parse.User);
query.find({
success: function(results){
var users = [];
//extract out user names from results
for(var i = 0; i < results.length; ++i){
users.push(results[i].get("username"));
}
response.success(users);
console.log(JSON.stringify(users));
}, error: function(error){
response.error("Error");
}
});
});
Thanks