Skip to content

How to use a query in new modular firestore #3203

Answered by gustavo-alarcon
m8xp0w3r asked this question in Q&A
Discussion options

You must be logged in to vote

Hi there !

I use the following approach, perhaps it could help you.

getUsers(): Observable<User[]> {
    const usersCollection: CollectionReference<User> = collection(
      this.firestore,
      'users'
    ) as CollectionReference<User>;

    return collectionData<User>(
      query(usersCollection, orderBy('createdAt', 'desc')),
      {
        idField: 'uid',
      }
    );
  }

Have a good day buddy !

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@m8xp0w3r
Comment options

Answer selected by m8xp0w3r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants