Search code examples
firebasegoogle-cloud-firestoreangularfire

Where does AngularFire (using Firestore) actually filter data?


According to this tutorial about querying collections:
https://github.com/angular/angularfire/blob/master/docs/firestore/querying-collections.md
filtering in the angularFire can be done it two ways:

  • using ref, for example: afs.collection('items', ref => ref.where('size', '==', 'large'))
  • using pipe, for example afs.collection('items').valueChanges().pipe(filter(...))

The question is, where the filtering is actually happening in the first option. Reasonable would be to process it on the server-side, however, I couldn't find any information about it in the documentation, in case of large databases fetching whole collections at first might be extremely expensive.


Solution

  • In the first option the filtering is done on the Firestore servers, and you can use any regular Firestore query operation. I'd only recommend piping into a client-side filter if your use-case can't be implement as a Firestore query, and you can predict how big your data set will be.