【问题标题】:Parse Cloud function returns null解析云函数返回 null
【发布时间】:2014-05-12 10:28:26
【问题描述】:

我需要查询我的安装类,所以我不得不为此使用 Parse Cloud。我正在将地图作为参数从 android 传递给云函数,并将其用于另一个查询,但它给了我 null:

这是我的云功能:

Parse.Cloud.define("hello", function(request, response) {
  Parse.Cloud.useMasterKey();
  var query = new Parse.Query("_Installation");
  query.matchesQuery("user", request.params.get("query"))
  query.find({
    success: function(results) {
      response.success(results.length);
    },
    error: function() {
      response.error("failed");
    }
  });
});

在安卓上:

Map<String, ParseQuery> map = new HashMap();
map.put("query", innerQuery);

 ParseCloud.callFunctionInBackground("hello", map, new FunctionCallback<String>() {
                            @Override
                            public void done(String o, ParseException e) {
                                if(e==null)
                                 Log.d("debug", "cloud function result: " + o);
                                else
                                    Log.d("debug", "cloud function error: " + e.getMessage());
                            }
                        });

上面的代码返回“云函数结果:null”。 顺便说一句,我对 javascript 不是很熟悉。

更新: 当我将其更改为request.params.query 时,它给了我这个错误:

Input: {"query":{"where":{"Student_ID":{"$regex":"\\Q13-0699-678\\E"}},"className":"_User"}}
  Failed with: TypeError: Object #<Object> has no method 'toJSON'
    at Object.b.Query.matchesQuery (Parse.js:3:13613)
    at main.js:7:9

【问题讨论】:

    标签: javascript android parse-platform


    【解决方案1】:

    要拉取传递给 ParseCloud 函数的变量,您可以这样拉取它:

    query.matchesQuery("user", request.params.query)
    

    【讨论】:

    • 我也试过这个,它给了我一个错误:Object # has no method 'toJSON'
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-04
    • 2019-02-27
    • 1970-01-01
    • 1970-01-01
    • 2014-07-24
    • 2013-03-29
    相关资源
    最近更新 更多