3

I've been looking for an example on how to use Parse.com queries. It's been really vague. I think it should start with:

ParseQuery query=ParseQuery.getQuery(<Class(aka table name)>);

But then, i've got no idea. You can do something like

query.whereEqualsTo(<collumn>,value)

In that case i get the 'value' back if it exists. What I am trying to do is. I got a table with the collumns ID and Name. I know what the ID is, it is 0. So now I want to know what Name belongs to the ID = 0.. But what query should I use, I have no idea ...

3 Answers 3

4

Parse's Android Guide has a basic query example here which will return the first object which matches your constraints:

ParseQuery<ParseObject> query = ParseQuery.getQuery("YourClassName");
query.whereEqualTo("ID", "someID");
query.getFirstInBackground(new GetCallback<ParseObject>() {
  public void done(ParseObject object, ParseException e) {
    if (object == null) {
      Log.d("score", "The getFirst request failed.");
    } else {
      Log.d("score", "Retrieved the object.");
    }
  }
});
Sign up to request clarification or add additional context in comments.

1 Comment

if i want to find list of user whose username starts from abc then how will i do @Hector Ramos
3

I would not recommend using getFirstInBackground for getting a query, it is much better to use findInBackGround and then filtering the value you are looking for.

Comments

1

To find the list of user whose username starts with abc,You can use the condition

query.whereStartsWith("username", "abc");

So the entire query looks as

ParseQuery<ParseObject> query = ParseQuery.getQuery("YourClassName");
query.whereStartsWith("username", "abc");
query.findInBackground(new FindCallback<ParseObject>() {
  public void done(List<ParseObject> object, ParseException e) {
    if (object == null) {
      Log.d("score", "The getFirst request failed.");
    } else {
      Log.d("score", "Retrieved the object.");
    }
  }
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.