Javascript 解析云代码-在“中查询用户问题”;“正常”;功能

Javascript 解析云代码-在“中查询用户问题”;“正常”;功能,javascript,function,parse-platform,parameter-passing,parse-cloud-code,Javascript,Function,Parse Platform,Parameter Passing,Parse Cloud Code,当使用“标准”函数时,我无法获取云代码来查询用户 如果我定义函数(如下所示),它可以正常工作 Parse.Cloud.define("findUser1", function(request, response){ Parse.Cloud.useMasterKey(); var query = new Parse.Query(Parse.User); query.equalTo("objectId", "2FSYI1hoJ8"); // "2FSYI1hoJ8" is the

当使用“标准”函数时,我无法获取云代码来查询用户

如果我定义函数(如下所示),它可以正常工作

Parse.Cloud.define("findUser1", function(request, response){
   Parse.Cloud.useMasterKey();
   var query = new Parse.Query(Parse.User);
   query.equalTo("objectId", "2FSYI1hoJ8"); // "2FSYI1hoJ8" is the objectId of the User I am looking for
   query.first({
       success: function(user){
       response.success(user);
   },
   error: function(error) {
       console.error(error);
       response.error("An error occured while lookup the users objectid");
   }
   });
 });
在此版本中,将调用函数,但其中的查询将不会

function findThisUser(theObject){
    console.log("findThisUser has fired... " + theObject); //confirms "theObject" has been passed in
    Parse.Cloud.useMasterKey();
    var query = new Parse.Query(Parse.User);
    query.equalTo("objectId", "2FSYI1hoJ8"); // "2FSYI1hoJ8" is the value of "theObject", just hard coded for testing
   query.first({
       success: function(users){
       console.log("the user is... " + users);
       // do needed functionality here
   },
       error: function(error) {
       console.error(error);
   }
   });
};
云代码不允许全局变量,我也不知道如何将一个变量从另一个传递到“已定义”函数。这是至关重要的,因为必须调用外部函数才能在返回的用户上运行所需的任务。(这种情况发生在其他地方,并且必须在其他事情发生之后发生。这是一个确认,应该也被其他函数使用)迄今为止发现的所有潜在信息都没有帮助,我在服务器端javascript方面的唯一经验就是我从其他云代码中拼凑出来的东西


你知道我遗漏了什么吗

这个链接可能会有帮助,我昨天遇到了类似的问题,在移动了一点代码并得到了响应之后。success(user);在我的作用下,一切都很顺利

不是你的问题,但这可能会有所帮助

以下是我现在使用的代码:

Parse.Cloud.define("getUserById", function (request, response) {
//Example where an objectId is passed to a cloud function.
var id = request.params.objectId;

Parse.Cloud.useMasterKey();
var query = new Parse.Query(Parse.User);
query.equalTo("ObjectId", id);

query.first(
{
    success: function(res) {
        response.success(res);
    },
    error: function(err) {
        response.error(err);
    }
});

}))

原来这是我需要的代码的一部分。。。(最终不需要“normal”函数)我还必须使用参数调用已定义的函数。这是我需要的另一部分->
Parse.Cloud.run('thisFunction',{“objectId”:objectId})
这允许我传递需要在查询中查找的objectId。非常感谢。