MindBrain
MindBrain

Reputation: 7768

Retrieve the most recent from the parse database by sorting

I am new to Parse. I have a Class in parse which has the following fields :objectId entryTime exitTime. So I have many records with the same objectID and a different entryTime and exitTime. I want to be able to retrieve the most recent record from this class with the ObjectId and the most recent entryTimeStamp. How can I acheive this ? So example of the records in my Class are as follows

 ObjectId            entryTime                          exitTime
1. O4ZnG0cr6C   Sat Feb 21 17:28:43 EST 2015  Sat Feb 21 17:28:43 EST 2015
2. O4ZnG0cr6C   Sat Feb 21 17:28:40 EST 2015  Sat Feb 21 17:29:43 EST 2015

If the current time is Sat Feb 21 17:28:44 EST 2015 I want to retrieve the top most record from this list. Thank you.

Upvotes: 1

Views: 48

Answers (1)

nick9999
nick9999

Reputation: 601

You can use ascending() or descending().

For example if your query is called query, query.ascending("parameter you want to sort") should sort the results for you.

If that doesn't work you can try query.orderByAscending("...")

Note that the methods only take in strings/string variables.

Upvotes: 2

Related Questions