我如何查询 firestore 中的两个 where 语句
How can i Query two where statements in firestore
我想做的是使用 ionic 和 angular 框架在 firestore 中查询两个 where 语句,但问题是我知道如何执行单个 where 语句而不是两个。那么如何实现呢。
我用来获取查询的代码是这样的:
getgame(id)
{
return this.afs.collection<review>('games', ref =>
ref.where(
'Euserid', '==', id
)).snapshotChanges().pipe(
map(actions => actions.map(a => {
const data = a.payload.doc.data();
const id = a.payload.doc.id;
return { id, ...data };
})))
}
所以你可以再添加一个.where
getgame(id) {
const ref = this.afs.collection<review>('games');
return
ref
.where('Euserid', '==', id)
.where('x' , '==','y'))
.snapshotChanges().pipe(
map(actions => actions.map(a => {
const data = a.payload.doc.data();
const id = a.payload.doc.id;
return { id, ...data };
})))
}
或类似的东西。
结帐:https://firebase.google.com/docs/firestore/query-data/queries#compound_queries
我想做的是使用 ionic 和 angular 框架在 firestore 中查询两个 where 语句,但问题是我知道如何执行单个 where 语句而不是两个。那么如何实现呢。
我用来获取查询的代码是这样的:
getgame(id)
{
return this.afs.collection<review>('games', ref =>
ref.where(
'Euserid', '==', id
)).snapshotChanges().pipe(
map(actions => actions.map(a => {
const data = a.payload.doc.data();
const id = a.payload.doc.id;
return { id, ...data };
})))
}
所以你可以再添加一个.where
getgame(id) {
const ref = this.afs.collection<review>('games');
return
ref
.where('Euserid', '==', id)
.where('x' , '==','y'))
.snapshotChanges().pipe(
map(actions => actions.map(a => {
const data = a.payload.doc.data();
const id = a.payload.doc.id;
return { id, ...data };
})))
}
或类似的东西。
结帐:https://firebase.google.com/docs/firestore/query-data/queries#compound_queries