Firebase Flatter Firestore:使用startAtDocument的结果不一致
我正在使用Web上的FlatterFireStore进行分页查询。当我尝试使用“startAtDocument”获取结果的第二页时,结果有时会显示一个文档 下面是我的简单测试用例:Firebase Flatter Firestore:使用startAtDocument的结果不一致,firebase,flutter,google-cloud-firestore,flutter-web,Firebase,Flutter,Google Cloud Firestore,Flutter Web,我正在使用Web上的FlatterFireStore进行分页查询。当我尝试使用“startAtDocument”获取结果的第二页时,结果有时会显示一个文档 下面是我的简单测试用例: Future<void> loadSendQueueSIMPLETTEST(SendQueryType theType) async { final num PAGE_LENGTH = 3; ObservableList<DocumentSnapshot> sendQueueD
Future<void> loadSendQueueSIMPLETTEST(SendQueryType theType) async {
final num PAGE_LENGTH = 3;
ObservableList<DocumentSnapshot> sendQueueDocsLocal;
QuerySnapshot snap;
// We're doing an initial page query
snap = await Firestore.instance.collection('departments')
.document(departmentID)
.collection('send_queue')
.orderBy('created')
.limit(PAGE_LENGTH)
.getDocuments();
sendQueueDocsLocal = new ObservableList.of(snap.documents);
sendQueueDocsLocal.forEach((element) {
print("GOT SEND QUEUE DOCS: ${element.documentID}");
});
DocumentSnapshot startDoc = sendQueueDocsLocal[2];
print("DOING PREV QUERY startAt: ${startDoc.documentID}");
snap = await Firestore.instance.collection('departments')
.document(departmentID)
.collection('send_queue')
.orderBy('created')
.startAtDocument(startDoc)
.limit(PAGE_LENGTH)
.getDocuments();
sendQueueDocsLocal.clear();
sendQueueDocsLocal.addAll(snap.documents);
sendQueueDocsLocal.forEach((element) {
print("SECOND SEND QUEUE DOCS: ${element.documentID}");
});
}
如果我将开始文档更改为另一个文档(不同的索引),如:
DocumentSnapshot startDoc=sendQueueDocsLocal[1]代码>
结果看起来不错:
GOT SEND QUEUE DOCS: ahkiflypgVFeUgk6e3Kk
GOT SEND QUEUE DOCS: 7NtDiDR5hwSulB8SOou5
GOT SEND QUEUE DOCS: ioIXHJJKsuPXA7g5Bks2
DOING PREV QUERY startAt: 7NtDiDR5hwSulB8SOou5
SECOND SEND QUEUE DOCS: 7NtDiDR5hwSulB8SOou5 <--- This looks right!
SECOND SEND QUEUE DOCS: ioIXHJJKsuPXA7g5Bks2
SECOND SEND QUEUE DOCS: Th3pHayGzqA1y1i3UTSf
获取发送队列文档:ahkiflypgfeugk6e3kk
已获取发送队列文档:7NtDiDR5hwSulB8SOou5
已获取发送队列文档:ioixhjksupxa7g5bks2
正在执行上一个查询开始:7NtDiDR5hwSulB8SOou5
第二个发送队列文档:7NtDiDR5hwSulB8SOou5
GOT SEND QUEUE DOCS: ahkiflypgVFeUgk6e3Kk
GOT SEND QUEUE DOCS: 7NtDiDR5hwSulB8SOou5
GOT SEND QUEUE DOCS: ioIXHJJKsuPXA7g5Bks2
DOING PREV QUERY startAt: 7NtDiDR5hwSulB8SOou5
SECOND SEND QUEUE DOCS: 7NtDiDR5hwSulB8SOou5 <--- This looks right!
SECOND SEND QUEUE DOCS: ioIXHJJKsuPXA7g5Bks2
SECOND SEND QUEUE DOCS: Th3pHayGzqA1y1i3UTSf