Flutter Firestore:使用startAtDocument的结果不一致

问题描述

我正在Web上使用Flutter Firestore进行分页查询。当我尝试使用“ startAtDocument”获取结果的第二页时,结果有时会显示一个文档。

这是我的简单测试用例:

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[2]; 我得到这些输出:

GOT SEND QUEUE DOCS: ahkiflypgVFeUgk6e3Kk
GOT SEND QUEUE DOCS: 7NtDiDR5hwSulB8SOou5
GOT SEND QUEUE DOCS: ioIXHJJKsuPXA7g5Bks2

DOING PREV QUERY startAt: ioIXHJJKsuPXA7g5Bks2

SECOND SEND QUEUE DOCS: Th3pHayGzqA1y1i3UTSf   <-- I expected this to be ioIXHJJKsuPXA7g5Bks2
SECOND SEND QUEUE DOCS: FznOTVIkPXnJi2co7yCp
SECOND SEND QUEUE DOCS: U7EtpyWIBsK6xlUJp43A

如果我将起始文档更改为另一个文档(不同的索引),例如: 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

在某些情况下,startAtDocument的行为是否有所不同?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...