Reputation: 1866
I am trying to get the last 1000 items from firestore and then sort them in ascending. So I tried
connection()
.collection(`somecollection`)
.orderBy("timestamp", "desc")
.limit(1000)
.orderBy("timestamp")
Having orderBy twice doesn't seem to work. But works with one orderBy I know I could do this in client but is it possible to run this am I missing something here.
Upvotes: 0
Views: 346
Reputation: 1859
You don't even need to orderBy by ascending, as it is by default.
connection()
.collection(`somecollection`)
.limit(1000)
EDIT:
Firestore doesn't support the functionality you are looking for, so you need to query the initial data in a descending order, and the on client sort it in the way you need
connection()
.collection('somecollection')
.orderBy('timestamp', 'desc')
.limit(1000);
Upvotes: 3