# How can I get a newest collection records?

**URL:** <https://community.parseplatform.org/t/how-can-i-get-a-newest-collection-records/928>\
**Category:** Parse Server 📡\
**Created:** [October 12, 2020, 1:43pm UTC](https://community.parseplatform.org/t/how-can-i-get-a-newest-collection-records/928 "2020-10-12T13:43:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andy](https://community.parseplatform.org/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@Andy](https://community.parseplatform.org/u/Andy)\
**Post date:** [October 12, 2020, 1:43pm UTC](https://community.parseplatform.org/t/how-can-i-get-a-newest-collection-records/928/1 "2020-10-12T13:43:57Z")

</div>

With SQL and incremental id I could just compare by id.  
Mongo also has sortable objectId but there is one nuance:

> While [ObjectId](https://docs.mongodb.com/manual/reference/bson-types/#objectid) values should increase over time, they are not necessarily monotonic. This is because they:
> 
> - Only contain one second of temporal resolution, so ObjectId values created within the same second do not have a guaranteed ordering, and
> - Are generated by clients, which may have differing system clocks.

In my case clients don’t generate objects but the first part is still important.  
At the very beginning I thought about comparing by `createdAt`, but also had worry about posibility of multiple records with the same value of `createdAt` (even if its resolution in ms). I’m pretty sure that is very unlikely but my inner perfectionist is suffering. So I thought to send info about latest current record from client: createdAt (for gt **e** comparing) and objectId (filter it from result).

May be you know more simple solution for such common task.

---

<div class="post-metadata">

**Author:** ![davimacedo](https://community.parseplatform.org/user_avatar/community.parseplatform.org/davimacedo/32/316_2.png) [@davimacedo](https://community.parseplatform.org/u/davimacedo)\
**Post date:** [October 12, 2020, 4:08pm UTC](https://community.parseplatform.org/t/how-can-i-get-a-newest-collection-records/928/2 "2020-10-12T16:08:55Z")

</div>

Parse Server does not use the MongoDB object id default implementation and as long as I know you cannot rely on Parse object id to sort by creation date. I’d go just with createdAt, but you can also use objectId to make sure that two objects with the same createdAt value will be ordered always in the same way.
