reactjs - 我如何在firebase中使用.where?
问题描述
我有这部分代码来获取集合火力库
const db = getFirestore(app)
const getCollection = name => collection(db, name)
const collection = getCollection(db, 'chars')
const query = await collection.where('name', '==', value)
我收到错误.where
不是函数,怎么了?
未处理的拒绝(TypeError):collection.where 不是函数
解决方案
您正在使用新的模块化 SDK,其中所有功能都是顶级的。
要创建查询,请执行以下操作:
const query = query(collection, where('name', '==', value))
另请参阅有关构建查询的 Firebase 文档。
推荐阅读
- wordpress - 如何在二十六主题的商店页面中添加过滤器
- jquery - 获取 contentEditable div 的第一行
- php - php 线程在 cmd 中正确运行,但不在浏览器中运行。并给出“致命错误:在第 2 行的 C:\xampp\htdocs\test.php 中找不到类 'Thread'”错误
- javascript - 将程序 php 转移到 laravel php
- visual-studio-code - 通过Mac终端打开2个Visual Studio Code窗口
- apache - apache - htaccess if/else 与文件夹?
- r - caret::groupKFold 和验证/测试
- java - Java mkdir() 文件夹,您无法在其中创建子文件夹或文件(拒绝访问)
- jenkins - 使用参数安排 Jenkins 构建
- sap - HANA - 使用其他行的数据进行计算