Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm building an app where the users can write into my db and ask questions to other users, like a doctor app. Where the doctors can answer the questions.

I wanna order the questions by date, where I would like to order the questions by newest, and also the most popular.

I try to order the newest by the following:

date: "29 September 2019"

Firestore.instance
        .collection("Questions")
        .orderBy("date", descending: true) // 1 will be last, 31 will be latest
        .snapshots(),

But that seem not to work. So I wonder how I could order the data correctly from my query from firebase. Or do I have to store the date as a long in the firebase and then convert it maybe?

Also, I would like to order the most popular questions, based on how many users have watched that particular questions by:

questionsView: "3", questionsView: "1032" etc

Firestore.instance
        .collection("Questions")
        .orderBy("questionsView")
        .snapshots(),

But neither does this do the ordering correctly.

I saw a great post from the legendery Frank von Puffen but I didn't really understand that, so I wonder if somebody could help me out on this.

Here's his post: Ordering Data In FireStore

Best regards, Rusben

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.3k views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...