1

This code works in default ascending but as soon as I feed desc in orderby, it returns empty.

return bindFirestoreRef(
        'codesBatch',
        codeCollection
          .orderBy('createdOn', 'desc')
          .limit(payload.limit || 3)
          .startAfter(state.loadMoreLastCode || null),
  • What do you mean by "orderBy descending is not working". What exactly doesn't work? Please edit your question and add your database structure as a screenshot. – Alex Mamo Feb 13 '22 at 08:54

1 Answers1

3

.orderBy() 'desc' doesn't work with .startAfter() null.

The first call has to be without .startAfter() and for later, the above code will work.

bitski
  • 1,168
  • 1
  • 13
  • 20