我将我们在parse.com上的应用程序迁移到AWS上的解析服务器应用程序。 我的代码下面有一个问题,虽然这是在parse.com上运行
此功能是使用iOS设备中的文本和图片保存的帖子。 " savePostComment"的最后一部分似乎发生错误。
parse-server的版本是2.2.25。
Parse.Cloud.define("savePost", function(request, response){
...
Parse.Cloud.run(
"savePostImage",
request.params
).then(function(savePostImageResult){
...
return Parse.Cloud.run(
"savePostComment",
request.params
);
})
...
}
Parse.Cloud.define("savePostImage",function(request,response){
...
file.save().then(function(savedFileResult){
response.success(savedFileResult);
},function(error){
response.error("saveImage error : " + error);
});
});
Parse.Cloud.define("savePostComment",function(request,response){
var userData_objectId = request.params.userData_objectId;
var user = request.params.user;
var userData_pointer = request.params.userData_pointer;
var user_objectId = request.params.user_objectId;
var comment_text = request.params.comment_text;
var comment_location = request.params.comment_location;
...
postObject.set("comment_text",comment_text);
postObject.set("comment_location",comment_location);
...
if(userData_pointer){
...
} else if(!userData_pointer) {
// execute query
Parse.Promise.when(
Parse.Cloud.run(
"returnPFUser",
{"user_objectId":user_objectId}
),
Parse.Cloud.run(
"returnUserData",
{"userData_objectId":userData_objectId}
)
)
.then(function(returnPFUserResult,returnedUserData){
postObject.set("user",returnPFUserResult);
postObject.set("userData_objectId",userData_objectId);
postObject.set("userData_pointer",returnedUserData);
returnedUserData.set("lastPost",postObject);
// This part seems to occur error
return Parse.Promise.when([returnedUserData.save(),postObject.save()])
})
.then(function(savedUserData,savedPostObject){
response.success(savedPostObject);
},function(error){
response.error(error);
});
}
});
错误日志如下。
error: Failed running cloud function savePostComment for user undefined with:
Input: {"comment_location_latitude":35.75201777186803,"...
Error: {"code":141,"message":{}} functionName=savePostComment, code=141, ...
error: Error generating response. ParseError {
code: 141,
message: [Error: Cannot create a pointer to an unsaved Object.] } code=141, ...
任何想法都赞赏。 感谢您阅读此内容。