简体   繁体   English

我如何在 firebase 中使用 .where?

[英]How can i use .where in firebase?

I have this part of code to get a collection firebase我有这部分代码来获取集合 firebase

const db = getFirestore(app)
const getCollection = name => collection(db, name)
const query = await getCollection(db, 'movies').where('name', '==', 'any')

i am getting error in .where is not a function, what is the wrong?我在.where is not a function 中遇到错误,有什么问题?

Unhandled Rejection (TypeError): collection.where is not a function未处理的拒绝(TypeError):collection.where 不是函数

You're using the new modular SDK, where all functions are top-level.您正在使用新的模块化 SDK,其中所有功能都是顶级的。

To create a query, do:要创建查询,请执行以下操作:

const query = query(collection, where('name', '==', value))

Also see the Firebase documentation on building queries .另请参阅有关构建查询的 Firebase 文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我如何在 firebase 中使用按日期排序 - How can i use order by date in firebase 如何使用 firebase 火库“在哪里!=” - how to use firebase firestore "where! =" 如何使用 firebase 中的两个“ref”方法? - how can I use two 'ref' methods from firebase? 如何在Firebase中的应用程序中使用云功能 - How can i use cloud function with app in Firebase 如何使用承诺来查看是否加载了 firebase auth? - How can I use a promise to see if firebase auth is loaded? 如何使用 Firebase 9.x + Flow - How can I use Firebase 9.x + Flow 如何在 React 中使用配置 json 文件与 where 条件 - How can I use a config json file in React with where condition 我可以在没有数据库的情况下使用 Firebase Auth 吗? - Can I use Firebase Auth without a database? 如何在 Firebase 身份验证电子邮件模板的操作链接 URL 中使用 firebase 的语言代码 (myFirebase.auth().languageCode)? - How can I use firebase's language code (myFirebase.auth().languageCode) in my action link URL in Firebase Authentication email template? 如何使用按钮更改我网站上材料 UI 的主题? 这是我到目前为止的地方 - How can I use a button to change the Theme for material UI on my site? this is where I am so far
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM