Home > Net >  Is there a way to use the orderBy() function from firestore using getDocs?
Is there a way to use the orderBy() function from firestore using getDocs?

Time:01-02

I am currently trying to this (doesn't actually orderBy anything)

let articlesSnapshot = await getDocs(articlesRef, orderBy('timestamp'));

In the documentation they only show this use case using queries rather than getDocs... Is there a way around this?

CodePudding user response:

The trick is to create a query like this:

let articlesSnapshot = await getDocs(query(articlesRef, orderBy('timestamp')));
  • Related