javascript - 从 Firestore 集合中获取多个文档时搜索两个查询
问题描述
所以我有
let dbREF = db
.collection("Users")
.doc("mQ4lxHU1sQhKlSmYYkik5F4dapz1")
.collection("listings");
我有
dbREF
.where("state", "==", uState)
.get()
.then((querySnapshot) => {
并且我基本上从集合 dbREF 中获取了多个与.where state === uState 匹配的文档。我想弄清楚的是如何搜索两个查询。
我试着这样做
dbREF
.where("state", "==", uState && "make", "==", selectedMake)
.get()
.then((querySnapshot) => {
但这没有用。我不仅要查找值为 uState 的状态,还要查找值为 selectedMake 的状态。我想知道是否有人可以指出我如何做到这一点的正确方向。非常感谢=]
解决方案
您可以where
多次调用,条件将被“与”在一起。所以:
dbREF
.where("state", "==", uState)
.where("make", "==", selectedMake)
.get()
另请参阅有关复合查询的 Firebase 文档部分。
推荐阅读
- android - 如何防止 Line Reader 跳过第一行?
- javascript - Vanilla JS Jest 测试点击事件
- python - 如何更改 Python sys.path 以防止在 pip 安装指向错误目录的 Python 包时发生 Permission Denied?
- c# - 依赖于被调用接口的其他成员的单元测试方法
- r - 计算变量内区间的平均值
- python - 设置标志后线程不会停止
- html - CSS height 属性调整 iframe 大小错误
- python - python pandas数据框将列重命名为多索引列
- c# - 可选地使用必填字段和 ASP.NET MVC 数据注释
- php - dyld:库未加载:/usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib、php-fpm、php5.6