Parse.com query returning 0 results when in the Data browser I can see there are 2 results

落花浮王杯 提交于 2019-12-22 01:09:33

问题


I am using Parse in my android application, and I and doing the following basic query:

    List<ParseObject> activityList = null;
    ParseQuery<ParseObject> query = ParseQuery.getQuery("Activity");
    query.setLimit(10);
    try {
        activityList = query.find();
    } catch (ParseException e) {
        e.printStackTrace();
    }

    Toast.makeText(Main.this, "Test "+activityList.size(), Toast.LENGTH_LONG).show();

the output I get is : Text 0

That is really weird! because I can definitively see in the Parse data browser that 2 results exist! Could this be something with ACL or whatever?

Here is a picture of my parse Data browser

As you can see, there are 2 records that exist.. Note I have no idea what ACL is so that might be the problem..


回答1:


Most likely its the undefined ACL causing your access problem ( entity in back end not being retreived by a GET ).

So, you should read the section of the android manual on ACL and on security. As a starter, when you create an object , you should construct an ACL with READ&WRITE for the owner and READ for others...

In android granting either world read/write or exclusive read/write to owner , that would be :

                aclOb1 = new ObjectMapper().createObjectNode();
                aclOb2 = new ObjectMapper().createObjectNode();
                aclOb2.put("read", true);
                aclOb2.put("write", true);

                String oid = $Get.current.user
                if(oid.equalsIgnoreCase("default")){
                    aclOb1.put("*", aclOb2);
                }else{
                    aclOb1.put(oid, aclOb2);
                }                                        
                rootOb.put("ACL", aclOb1);

For ACL example in JS , see createOnEnter method in the link



来源:https://stackoverflow.com/questions/22425666/parse-com-query-returning-0-results-when-in-the-data-browser-i-can-see-there-are

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!