AngularFIre: limit queries to users that has a specific value

Viewed 634

I'm using AngularFire to interact with my collections on firebase. I have a query which limit the number of queries, but with I also need, is to show only users which have a specific value. For example, I just want to show users which have profile pictures. How do I can do this in the query?

users: Observable<any[]>;

this.users = firestore.collection<User>('users', ref => ref.limit(10) ).valueChanges();

I looked for it on the documentation, but I can't find nothing that could help me

I think it could be something like:

this.users = firestore.collection<User>('users', ref => ref.limit(10) ).where("photoUrl", "==", true).valueChanges();

but it didn't work for me.

when I do that I got the error:

Property 'where' does not exist on type 'AngularFirestoreCollection'.

1 Answers

You might want to review the documentation on how to add a filter to a query in AngularFire. You want this instead:

this.users = firestore.collection<User>('users', ref =>
    ref.where("photoUrl", "==", true).limit(10)
).valueChanges();
Related