2014-04-01 128 views
1

我需要在我的Installation類上進行查詢,因此我不得不使用Parse Cloud進行查詢。我把地圖作爲參數從Android雲功能,使用它的另一個查詢,但它給了我零:Parse Cloud函數返回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"); 
    } 
    }); 
}); 

在Android上:

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。

UPDATE: 當我把它改成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 

回答

0

要拉傳遞到一個ParseCloud功能的變量,你會拉這樣的:

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

我也試過這個,它給了我一個錯誤:對象#沒有方法'toJSON' – danieljohngomez