我正在尝试查询 firestore 中的列表,该列表应按降序日期属性排序,并使用 startAfter 光标对结果进行分页。
正如您在下面的片段中看到的那样,一旦我将 orderBy('date', 'desc') 与 startAfter(lastDoc.date) 结合使用,这将失败。
我想知道我做错了什么。有任何想法吗?
// this actually works
// but it is sorted by ascending dates
db.collection('tanks')
.doc(tankId)
.collection('documentations')
.orderBy('date')
.startAfter(lastDoc.date)
.limit(pageSize)
.get()
// this even works...
// but has no cursor (startAfter) set for pagination
db.collection('tanks')
.doc(tankId)
.collection('documentations')
.orderBy('date', 'desc')
.limit(pageSize)
.get()
// this is what i need
// but it returns always zero results
db.collection('tanks')
.doc(tankId)
.collection('documentations')
.orderBy('date', 'desc')
.startAfter(lastDoc.date)
.limit(pageSize)
.get()