我有一个事件表,它有一个名为&#34的列;与会者"这是_User的关系类型[多对多]。
我尝试了以下内容,以获取基于事件的objectId参加活动的所有_Users的列表。在下面的代码中,成功和错误回调是 not 被调用。 (SUCCESS或ERROR都没有打印到错误日志中。)
Parse.Cloud.define("cancelEvent", function(request, response) {
var query = new Parse.Query("Event");
query.get(request.params.eventId, {
success: function(event) {
// event.set("status", "cancelled");
// event.save();
// notify attendees of cancellation
var relation = event.relation("attendees");
var innerQuery = relation.query();
innerQuery.find({
success: function(attendees) {
console.error("SUCCESS");
},
error: function(error) {
console.error("ERROR");
}
});
event.save();
response.success();
},
error: function(object, error) {
console.error("Failed to cancel event.");
response.error(error);
}
});
});
答案 0 :(得分:0)
移动event.save(); response.success(); 像这样的成功回调内部
Parse.Cloud.define("cancelEvent", function(request, response) {
var query = new Parse.Query("Event");
query.get(request.params.eventId, {
success: function(event) {
// event.set("status", "cancelled");
// event.save();
// notify attendees of cancellation
var relation = event.relation("attendees");
var innerQuery = relation.query();
innerQuery.find({
success: function(attendees) {
console.error("SUCCESS");
event.save();
response.success();
},
error: function(error) {
console.error("ERROR");
}
});
},
error: function(object, error) {
console.error("Failed to cancel event.");
response.error(error);
}
});
});