user6740794
user6740794

Reputation:

How can I order the documents in Firestore?

How can I order the documents in Firestore? It looks like Firestore lists documents in alphabetic order by the ID I let Firestore automatically create. But I don't want that. I just want to see my newly added document added as the last document in the collection. How do I do that? Should I create my own alphabetic ID's?

Example of my collection in Firestore:

Example of my collection in Firestore

Upvotes: 3

Views: 2407

Answers (2)

Polymath
Polymath

Reputation: 871

If you have a timestamp field, you can add a filter on timestamp and sort results by desc. Do not add a filter condition.

enter image description here

Upvotes: 0

Doug Stevenson
Doug Stevenson

Reputation: 317958

Firestore is meant to scale massively. At that scale, it doesn't matter what order the documents appear in the console, because the console is useless for viewing massive numbers of documents within a collection.

If you still need an ordering in the console, you will have to come up with document IDs of your own.

Upvotes: 5

Related Questions