0
votes

In my query, how can I access an object in the Parse class? Like set the object awayTeam to equal the newAwayTeam object?

Something like

CloseGameTime.set("awayTeam", "the newAwayTeam object");

Original Code

    Parse.Cloud.job("CloseGameTime", function(request, response) {
 
  Parse.Cloud.useMasterKey();
  
  var query = new Parse.Query("Score");

  query.first({
    success: function(CloseGameTime) {

    var newAwayTeamVar = request.object.get("newAwayTeam");

      CloseGameTime.set("isGameTime", "NO");
      CloseGameTime.set("awayTeam", newAwayTeamVar);


      CloseGameTime.save(null, {
        success: function(CloseGameTime) {
          response.success("Successfully updated the server.");
        },
        error: function(CloseGameTime, error) {
          response.error("Could not save changes to the server.");
        }
      });
    },
    error: function(error) {
      response.error("Could not find object.");
    }
  });
});
2

2 Answers

1
votes

Shouldn't be too hard. I've done something similar on my parse cloud code so give this a shot:

var awayTeamObject = request.object.get("newAwayTeam");
CloseGameTime.set("awayTeam", awayTeamObject);
0
votes

I found that all you need to call is the success's function followed by .get.

var newAwayTeamVar = CloseGameTime.get("nextAwayTeam");

Whole Code:

Parse.Cloud.job("CloseGameTime", function(request, response) {
 
  Parse.Cloud.useMasterKey();
  
  var query = new Parse.Query("Score");

  query.first({
    success: function(CloseGameTime) {

     var newAwayTeamVar = CloseGameTime.get("nextAwayTeam");


      CloseGameTime.set("isGameTime", "NO");
      CloseGameTime.set("awayTeam", newAwayTeamVar);
      CloseGameTime.set("nextAwayTeam", "");


      CloseGameTime.save(null, {
        success: function(CloseGameTime) {
          response.success("Successfully updated the server.");
        },
        error: function(CloseGameTime, error) {
          response.error("Could not save changes to the server.");
        }
      });
    },
    error: function(error) {
      response.error("Could not find object.");
    }
  });
});