在我的查询中,如何访问Parse
类中的对象?
就像将对象awayTeam
设置为等于newAwayTeam
对象一样?
像
这样的东西CloseGameTime.set("awayTeam", "the newAwayTeam object");
原始代码
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.");
}
});
});
答案 0 :(得分:1)
不应该太难。我已经在我的解析云代码上做了类似的事情,所以请试一试:
var awayTeamObject = request.object.get("newAwayTeam");
CloseGameTime.set("awayTeam", awayTeamObject);
答案 1 :(得分:0)
我发现你需要调用的只是成功的函数,后跟.get
。
var newAwayTeamVar = CloseGameTime.get("nextAwayTeam");
整个代码:
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.");
}
});
});