Aha*_*ves 5 firebase flutter google-cloud-firestore
FutureBuilder 在类型时间戳字段上使用 Firestore 查询返回快照中没有数据。但是,没有 orderBy 的相同查询工作得很好。
我错过了什么?谢谢您的帮助。
// Working code
future: Firestore.instance.collection('messages').where('toid',isEqualTo: _emailID).getDocuments(),
builder: (context, snapshot) ...
// Not Working - returns to if(!snapshot.hasData)
future: Firestore.instance.collection('messages').where('toid',isEqualTo: _emailID).orderBy('_timeStampUTC', descending: true).getDocuments(),
builder: (context, snapshot) ...
Run Code Online (Sandbox Code Playgroud)
Rod*_*ata 10
我认为你错过了一个'here '_timeStampUTC,所以它应该是:
orderBy('_timeStampUTC', descending: true)
Run Code Online (Sandbox Code Playgroud)
编辑:
此外,您需要确保为toid和其他 for创建索引_timeStampUTC,这是在您尝试按不在您查询的位置中的属性进行排序时完成的。
| 归档时间: |
|
| 查看次数: |
12970 次 |
| 最近记录: |