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 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题