Flutter Firestore::我如何通过地图内的 field/value 来订购 firestore 查询?

Flutter Firestore: :How I can order firestore query by field/value inside map?

我试过了:

FirebaseFirestore.instance
        .collection('messages')                  
        .orderBy('sentDate', descending: false)
        .snapshots(), 

但是没用。

如果您想按地图中特定条目的 sendDate 排序,您可以使用圆点表示法:

.orderBy('167361790.sentDate', descending: false)

如果您想对动态选择的地图条目的 sentDate 进行排序,这对于您当前的数据模型是不可能的,您需要修改您的数据模型以允许使用-案例.

例如,如果您想对最近 sentDate 上的消息进行排序,您应该向文档 latestSentDate 添加一个顶级字段,每当您写入地图时更新该字段,然后对其进行排序。