0

I am in Angular 4, I need to compose a query with the multiple where clauses. Here is my code below. How can I add the multiple where clauses into the queryfn?

this.db.collection('cities', x => x.where('city', '==', 'CA'))
      .snapshotChanges()

Thank you

DavidB
  • 313
  • 1
  • 8
  • 23

1 Answers1

0

As you can see by this related question, it is possible to either chain or append your clauses to the query reference:

// option 1
const ref = admin.firestore().collection('collectionName')
const query = ref.where('foo', '==', 'bar').where('baz', ==, 'buz')

query.get()
  .then(snapshot => {
    snapshot.forEach(res => console.log(res.data())
  })

// option 2
const ref = admin.firestore().collection('collectionName')
const query = ref.where('foo', '==', 'bar')
query.where('biz', <=, 5)
query.where('zaz', ==, 9)

query.get()
  .then(snapshot => {
    snapshot.forEach(res => console.log(res.data())
  })
kuzyn
  • 1,905
  • 18
  • 30