drqja5919276 2014-05-28 14:39
浏览 61

解析查询总是返回空结果

Hello I was trying to uses Parse.com's Cloud Code API and I was trying to create a code snippet that will query the data that shows in my data browser

My cloud code is

Parse.Cloud.define("getDriver", function (request, response){
    var User = Parse.Object.extend("User");
    var query = new Parse.Query(User);
    var lastlogin;

    //response.success({"obj":request.params.objectId}); //works

    query.equalTo("objectId",request.params.objectId);
    query.find({
        success: function(objs) {

            response.success({"driver_id":objs.length});

        },
        error: function(error) {
            // The object was not retrieved successfully.
            // error is a Parse.Error with an error code and description.
        }
    });
});

I am calling the cloud code with php curl , the code is

$ch =curl_init("https://api.parse.com/1/functions/getDriver/");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,true);
curl_setopt($ch,CURLOPT_CAINFO,"ca-bundle.crt");

curl_setopt($ch,CURLOPT_HTTPHEADER,array('X-Parse-Application-Id:   APPLICATION_ID','X-Parse-REST-API-Key: API_KEY', 'Content-Type: application/json'));

curl_setopt($ch,CURLOPT_POSTFIELDS, "{\"objectId\": \"NDpoVvFcGP\"}");
  //execute post
$result = curl_exec($ch);

//close connection
curl_close($ch);

My problem is that the query always gives an empty result even though the correct objectId is being passed: NDpoVvFcGP

I cannot figure out this one. What might be the problem? Can someone please help?

Thanks

  • 写回答

2条回答 默认 最新

  • dongqing4070 2014-05-29 21:09
    关注

    If you are querying the built-in User class, you should look at the documentation.

    Specifically you should create your User query as follows:

    var query = new Parse.Query(Parse.User);
    

    Internally I think they use "_User" as the class name, which is why your query failed when using "User". Best to just use the documented and supported method of querying the User class.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000
  • ¥30 ppOCRLabel导出识别结果失败
  • ¥15 Centos7 / PETGEM
  • ¥15 csmar数据进行spss描述性统计分析
  • ¥15 各位请问平行检验趋势图这样要怎么调整?说标准差差异太大了
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题