【问题标题】:how to sort the documents in a collection in cloud firestore by their date of creation instead of their name?如何按创建日期而不是名称对 Cloud Firestore 集合中的文档进行排序?
【发布时间】:2020-09-13 08:08:02
【问题描述】:

保存到云 Firestore 中的数据按名称排序,但我希望它按我将其保存到云中的时间排序,我该怎么做?

这是我的代码:

_fireStore.collection('orders')
    .document(_costumerPhoneNumber)
    .setData({
        'Phone Number': _costumerPhoneNumber,
        'Name': _costumerName,
        'NeighborHood/Complex': _costumerNeighboorHood,
        'Street/Building Number': _costumerStreetNumber,
        'House/Apartment Number': _costumerHouseNumber,
        'Shop Chosen': _selectedShop,
    });

【问题讨论】:

  • 只使用纪元时间。而不是名字
  • 我不明白你能解释一下
  • 您无法控制数据保存的顺序。您只能在查询时订购数据。

标签: flutter dart google-cloud-firestore


【解决方案1】:

查询 collectionReference = _fireStore.collection("orders").orderBy('field');

【讨论】:

    猜你喜欢
    • 2015-01-10
    • 2020-07-05
    • 1970-01-01
    • 1970-01-01
    • 2012-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多