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

StackOverflow https://stackoverflow.com/questions/22425666

  •  15-06-2023
  •  | 
  •  

Domanda

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

enter image description here

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

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top