我正在使用 AngularFire 与我在 firebase 上的收藏进行交互。我有一个限制查询数量的查询,但我还需要仅显示具有特定值的用户。例如,我只想向用户展示有个人资料图片的用户。我如何在查询中执行此操作?
users: Observable<any[]>;
this.users = firestore.collection<User>('users', ref => ref.limit(10) ).valueChanges();
我在文档中查找了它,但找不到任何可以帮助我的内容
我认为可能是这样的:
this.users = firestore.collection<User>('users', ref => ref.limit(10) ).where("photoUrl", "==", true).valueChanges();
但它对我不起作用。
当我这样做时,我收到错误:
Property 'where' does not exist on type 'AngularFirestoreCollection'.
最佳答案
您可能想查看documentation关于如何在 AngularFire 中向查询添加过滤器。你想要这个:
this.users = firestore.collection<User>('users', ref =>
ref.where("photoUrl", "==", true).limit(10)
).valueChanges();
关于 Angular 火 : limit queries to users that has a specific value,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64591411/