我已经编写了云作业,这将更新上次评论论坛的日期,在论坛栏目中进行了最后更新:
Parse.Cloud.job("MigrateupdatedAtForumCommenttoForum", function(status) {
var ForumQuery = new Parse.Query('Forum');
ForumQuery.descending('updatedAt');
ForumQuery.limit(1000);
ForumQuery.greaterThan('comment_count',0);
ForumQuery.find().then(function(forums) {
for (var i=0; i<forums.length; i++) {
//var ForumComment = forums[i].relation('forum_comment');
var ForumCommentQuery = forums[i].relation('forum_comment').query();
ForumCommentQuery.descending('updatedAt');
ForumCommentQuery.first().then(function (comment) {
if (comment != null) {
forums[i].set('lastupdatedat', comment.updatedAt);
forums[i].save();
} else {
forums[i].set('lastupdatedat', forum.updatedAt);
forums[i].save();
}
});
}
status.success('Transfer Completed!');
}, function(error) {
status.success('Error in Transfer column data');
});
});
当我在Parse Job中托管它并执行预定作业时,给我错误。
错误详情如下:
E2015-10-09T09:32:03.990Z]v41 Ran job MigrateupdatedAtForumCommenttoForum with:
Input: {}
Result: TypeError: Cannot call method 'query' of undefined.
at new e (Parse.js:14:29896)
at e.<anonymous> (main.js:877:28)
at e.s (Parse.js:14:26859)
at e.n.value (Parse.js:14:26278)
at e.<anonymous> (Parse.js:14:26931)
at e.s (Parse.js:14:26859)
at Parse.js:14:27245
at i (Parse.js:14:27200)
at e.n.value (Parse.js:14:27230)
at e.s (Parse.js:14:26905)
我无法在Parse上运行代码作为云作业。当我在我的代码中编写函数时工作正常。