我需要查询我的安装类,因此我被迫使用 Parse Cloud。我将 map 作为参数从 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
最佳答案
要提取传递到 ParseCloud 函数的变量,您可以像这样提取它:
query.matchesQuery("user", request.params.query)
关于javascript - 解析云函数返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22789431/