Shaz
Shaz

Reputation: 302

How to write orderBy query in parse.com

I am building an Android messaging app using parse.com as backend. I want to find out top 10 users who have sent most number of messages.

parse.com doesn't support orderBy clause.

Database schema:

User(objectId[PK], username)
Message(objectId[PK], sender[ForeignKey], Receiver[ForeignKey]

could somebody please help me how to tackle this?

Upvotes: 1

Views: 934

Answers (1)

Marius Waldal
Marius Waldal

Reputation: 9952

You can order with ParseQuery addAscendingOrder(keyToSortBy);

So, if you have a field with number of sent messages (numberofmessages), the query would look like:

query.addAscendingOrder("numberofmessages");

http://www.parse.com/docs/android/api/com/parse/ParseQuery.html#addAscendingOrder(java.lang.String)

Upvotes: 1

Related Questions