Search code examples
firebasegoogle-cloud-firestorefirebase-console

how to add documents to bottom of the document column in Cloud Firestore through the Firebase console


I'm adding data to cloud Firestore through the Firebase Console. I've added a collection and the corresponding documents and fields. When I click on " ADD DOCUMENT", the new document appears randomly (as far as I can make out) on the document column. I want the newly generated document to appear at the bottom of the document column. The order matters when viewing the data on the app. The data is used in a recycler view. Is this possible?


Solution

  • Cloud Firestore does not order documents in the same way as the RTDB. Auto IDs are not time related. You will need to add a timestamp field and order your data by this field.

    You can read about this here.

    Important: Unlike "push IDs" in the Firebase Realtime Database, Cloud Firestore auto-generated IDs do not provide any automatic ordering. If you want to be able to order your documents by creation date, you should store a timestamp as a field in the documents.