![](/img/trans.png)
[英]How to sort by a field in a sub-collection in firebase cloud firestore in flutter
[英]How can I sort a collection in Firebase with Flutter?
我试图通过将不同用户的高分存储在 Firebase 中来显示 Flutter 的排行榜系统,但我无法弄清楚如何对用户进行排序,因此只有前 10 名出现在集合中,分数低于用户的。 到目前为止,我得到了它,所以它将它限制在总分前十名,但我无法让它只显示得分低于用户的前十名。
// Get Users stream
Stream<List<HighscoreData>> get score {
return scoreCollection
.orderBy('score', descending: true,).limit(5)
.snapshots()
.map(_scoreListFromSnapshot);
}
让我们试试这个它对你有用
Firestore.instance
.collection("users")
.orderBy('score', descending: true,).getDocuments()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.