颤振 Firestore 结束之前文档不起作用


await FirebaseFirestore.instance
.collection('NewCardsList')
.orderBy('timestamp')
.endBeforeDocument(oldestDocID)
.limitToLast(_theNumberOfFetchingOldCard)
.get()
.then(...);

我在3-4个月前制作了这个代码,效果很好。

然而,它突然不起作用。。。

我正在用每一行检查带有断点的代码,在"之后没有任何反应;。然后((行";。(不转到下一行(

我发现,如果我去掉";。endBeforeDocument((方法";。

DocumentSnapshot oldestDocID = await FirebaseFirestore.instance
.collection('NewCardsList')
.doc(cardManagementProvider.newCardsIDList.last)
.get();
print('############# ${oldestDocID.id}');

此代码用于在"中获取DocumentSnapshot;。endBeforeDocument((方法";。

我可以用print((看到正确的结果来查看DocumentSnapshot。

请给我一些关于这个问题的意见。

我用startAfterDocument((更改逻辑后解决了这个问题。

但我仍然无法理解为什么它不能与endBeforeDocument((一起工作

await FirebaseFirestore.instance
.collection('NewCardsList')
.orderBy('timestamp', descending: true)
.startAfterDocument(oldestDocID)
.limit(_theNumberOfFetchingOldCard)
.get()
.then(...);

最新更新