【问题标题】:Firestore ODM order by DateTime in Flutter在 Flutter 中按 DateTime 排序的 Firestore ODM
【发布时间】:2022-06-10 18:08:23
【问题描述】:

有没有办法使用 Cloud Firestore ODM 在 Flutter 中按 DateTime 订购 Firestore 记录? 在我的飞镖模型中,我有一个 created_at 类型的字段 DateTime,我想使用该字段订购记录。

part 'item.g.dart';
class Item with Change Notifier {
     // other fields excluded for brevity

     @JsonKey(fromJson: timestampConvertFromJson)
     late DateTime createdAt;

     static DateTime timestampConvertFromJson(Timestamp timestamp) {
       return timestamp.toDate();
     }
}

生成的item.g.dart 不包含 createdAt 订单查询。但是,如果我将类型更改为 Stringint,则会生成 orderByCreatedAt 查询。为什么会这样?更重要的是如何使用DateTime 订购?

【问题讨论】:

标签: flutter firebase dart google-cloud-firestore


【解决方案1】:

这是 Firestore ODM 中的一个已知问题,目前正在处理中:https://github.com/firebase/flutterfire/discussions/7475#discussioncomment-1901156

【讨论】:

    猜你喜欢
    • 2020-12-22
    • 2021-01-12
    • 2020-09-14
    • 2019-05-27
    • 2021-06-03
    • 1970-01-01
    • 2019-10-20
    • 2023-01-15
    • 1970-01-01
    相关资源
    最近更新 更多