【问题标题】:How to get min/max price in a collection Firestore Flutter如何在集合 Firestore Flutter 中获得最低/最高价格
【发布时间】:2021-11-04 06:39:20
【问题描述】:

我有一个酒店所有房间的房间集合。我想在所有该系列中获得最低价格。

我目前的方法代码:

Firestore 集合:

【问题讨论】:

  • 您的收藏中是否缺少房间说明符?应该是 instance.collection("rooms/single/room")?
  • 请不要有代码图片

标签: database firebase flutter dart google-cloud-firestore


【解决方案1】:
FirebaseFirestore.instance.collectionGroup("rooms")
                            .orderBy("price")
                            .limit(1)
                            .get();

试试这个以获得最低的)

FirebaseFirestore.instance.collectionGroup("rooms")
                                .orderBy("price",descending: true)
                                .limit(1)
                                .get();

试试这个可以买到很贵的 *注意您在文件中的收藏必须具有相同的名称(房间)

【讨论】:

    猜你喜欢
    • 2014-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-12
    相关资源
    最近更新 更多