'vuexfire firestore orderBy descending is not working, works in acending

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),


Solution 1:[1]

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

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 bitski