我在Angular 4中,我需要用多个where子句组成一个查询。这是我的代码如下。 如何将多个where子句添加到queryfn中?
this.db.collection('cities', x => x.where('city', '==', 'CA'))
.snapshotChanges()
谢谢
答案 0 :(得分:0)
正如您在this related question所看到的那样,可以将您的子句链接或附加到查询引用:
// 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())
})