在sql中,我们可以使用'where'来选择我们想要的任何数据。 如何在 firestore 中做同样的事情,我使用 if 语句但它似乎不起作用
最佳答案
假设你想从用户集合中选择一个特定的用户
angularFirestore.collection('users', ref => ref.where('username', '==', 'doe'))
可以加入多个where子句
angularFirestore.collection('users',
ref => ref.where('username', '==', 'doe')
.where('age', '>=', '20'))
但是您只能在一个字段上使用范围比较。
右:
angularFirestore.collection('users',
ref => ref.where('age', '<=', '40')
.where('age', '>=', '20'))
错误:
angularFirestore.collection('users',
ref => ref.where('earning', '>=', '40000')
.where('age', '>=', '20'))
关于android - 如何在 Firestore 中使用 'where',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49842348/