UmaiZ
UmaiZ

Reputation: 133

Ionic firstore get specific data of collection

I am fetching data from firestore but stuck at one place. I need to fetch specific data which value is equal to doc collection. Please see image

enter image description here

As you see i have categoryID inside a doc. So i need all doc which have this value in their doc. Any fast solution how can i do this ?

This is my simple code i am fetching all questions by this but need to fech by categoryID

  public getQuestions(): Observable<{}[]> {
    return this.angularFirestore.collection("questions").valueChanges();
  }

Upvotes: 1

Views: 218

Answers (1)

Peter Haddad
Peter Haddad

Reputation: 80914

You need to query for example:

public getQuestions(): Observable<{}[]> {
return this.angularFirestore.collection("questions", ref => ref.where('categoryID', '==', id_here)).valueChanges();
} 

Check here for more info about angularfire:

https://github.com/angular/angularfire/blob/master/docs/firestore/querying-collections.md

Upvotes: 1

Related Questions