How to use a query in new modular firestore #3203
-
Hello everyone, getCollection<T>(collectionName: string, queryFn?: QueryFn): AngularFirestoreCollection<T> { return this.firestore.collection<T>(collectionName, queryFn); } With the modular version I probably will go like this: getCollection(collectionName: string, queryFn?: QueryFn): CollectionReference<DocumentData> { return collection(this.firestore, collectionName); } Unfortunately I did not find anything how to pass my (optional) Query here. Do you have any suggestions how I I can do this? Regards Nils |
Beta Was this translation helpful? Give feedback.
Answered by gustavo-alarcon Apr 16, 2022
Replies: 1 comment 1 reply
-
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 ! |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by m8xp0w3r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Hi there !
I use the following approach, perhaps it could help you.
Have a good day buddy !