【发布时间】:2020-12-25 08:25:12
【问题描述】:
在我的应用程序中,我有一个字段值为 threadCommentCount 的 cmets。我想使用 orderBy threadCommentCount 降序对 cmets 进行排序,然后使用 startAfter(lastThreadCommentCount) 继续分页。问题是当 threadCommentCount 为 0(其中很多)时,它每次都会返回相同的数据,因为它每次都从 0 开始。这是查询:
popularCommentsQuery = db
.collection('comments')
.where('postId', '==', postId)
.orderBy('threadCommentCount', 'desc')
.startAfter(startAfter)
.limit(15)
.get()
一旦threadComment计数为0,这将每次返回相同的cmets。我无法发送最后一个文档快照,因为我使用云函数并且我不想在get查询参数中发送documentSnapshot。我真的不在乎在 threadCommentCount 为 0 之后如何对 cmets 进行排序,我只需要不得到任何重复项。任何帮助都很棒!
【问题讨论】:
标签: node.js google-cloud-firestore pagination