Order Firestore data by TimeStamp in Ascending order

后端 未结 3 829
天涯浪人
天涯浪人 2021-01-03 23:51

I am storing Ideas posted by the application in Firestore. The data is stored in Firestore like this Ideas/{documentID}/IdeaObject. The issue is when I retr

3条回答
  •  甜味超标
    2021-01-04 00:02

    In my case, the vanilla version would be,

    firestoreDb.collection("ideas")
         .orderBy("timestamp", "asc")
    
    firestoreDb.collection("ideas")
         .orderBy("timestamp", "desc")
    

    "ideas" is the name of your collection

    "timestamp" is the key or field or column name to be used for sorting.

    "asc" or "desc" is the option to be used for the order

提交回复
热议问题