Tuesday, 1 June 2021

Firestore composite query pagination

Im trying to paginate a composite index query,

let size = data.length
let lastElement = data[size-1].commentCount

db.collection('user-content').orderBy('commentCount','desc').orderBy('likes', 'desc').startAfter(lastElement).limit(10).get()

But I'm currently getting this error message

[Unhandled promise rejection: FirebaseError: Function Query.startAfter() called with invalid data. Unsupported field value: undefined]

I think it has something to do with startAfter(lastElement)

I have the composite index turned on, and I'm getting data when I first load (without startAfter)

does anyone know how to paginate with composite query ?

Im using Expo SDK41, managed workflow.



from Firestore composite query pagination

No comments:

Post a Comment