Firebase Flatter Firestore查询嵌套子集合
我试图在Firebase中查询子集合,但我总是得到一个空列表 这是我的疑问:Firebase Flatter Firestore查询嵌套子集合,firebase,flutter,dart,google-cloud-firestore,Firebase,Flutter,Dart,Google Cloud Firestore,我试图在Firebase中查询子集合,但我总是得到一个空列表 这是我的疑问: Firestore.instance.collection('messages').where('idFrom', isEqualTo: userID).snapshots(); 我知道我这里有一个子集合和另一个子集合 /messages/RWzG98s92mVTZniofez6YoYsNhA3-tT2Q16n1FMZoTNZQOejtWuJdCmD2/RWzG98s92mVTZniofez6YoYsNhA3-tT2
Firestore.instance.collection('messages').where('idFrom', isEqualTo: userID).snapshots();
我知道我这里有一个子集合和另一个子集合
/messages/RWzG98s92mVTZniofez6YoYsNhA3-tT2Q16n1FMZoTNZQOejtWuJdCmD2/RWzG98s92mVTZniofez6YoYsNhA3-tT2Q16n1FMZoTNZQOejtWuJdCmD2/1579394957103
我的问题是如何查询这些类型的模型
因为Firstore查询总是很浅的,所以必须构建到要查询的子集合的路径
Firestore.instance
.collection('messages')
.document(...) // ID of the nested document
.collection(...). // ID of the nested subcollection
.where('idFrom', isEqualTo: userID);
没有办法避免给出这些嵌套ID。如果无法识别要查询的子集合的完整路径,则将无法访问其文档。由于Firstore查询总是很浅,因此必须构建要查询的子集合的路径
Firestore.instance
.collection('messages')
.document(...) // ID of the nested document
.collection(...). // ID of the nested subcollection
.where('idFrom', isEqualTo: userID);
没有办法避免给出这些嵌套ID。如果无法识别要查询的子集合的完整路径,则将无法访问其文档