Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use 'where' with AngularFire 7 new api?

I upgraded AngularFire to 7, and have a problem with using .where with collectionReference. So simply.. how to use it properly?

I tried to use 'collection' from '@angular/fire/firestore' like:

const ref = collection(this.firestore, 'collectionName');

but the ref has not 'where' or something.

I know that '@angular/fire/firestore' has also 'query' and 'where', but I don't know how to use it.

How to find documents in the collection using 'where' with a new API?

like image 282
Przemo Avatar asked Mar 21 '26 07:03

Przemo


1 Answers

I managed to figure this one out...

for single where statement use

const refq = query(ref,where('dir','==','T'))

for multiple where statements use

const wa:QueryConstraint[] = [where('dir','==','T'),where('day','==',23)]

const refq = query(ref,...wa)

to get the results use

collectionData(refq).subscribe()
like image 140
dsl400 Avatar answered Mar 23 '26 21:03

dsl400



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!