简体   繁体   English

检查 Firebase 实时数据库中是否存在条目(Python)

[英]Check if entry exists in Firebase Realtime Databse (Python)

I am currently trying to retrieve login information from my Realtime DB in Firebase.我目前正在尝试从 Firebase 中的实时数据库中检索登录信息。 图像

As an example, I want to detect whether the provided username already exists in the db.例如,我想检测提供的用户名是否已存在于数据库中。

Here is a code snippet I'm attemping to work with.这是我正在尝试使用的代码片段。

ref.child("Users").order_by_child("Username").equal_to("Hello").get()

It does not however work, and instead displays this message:但是它不起作用,而是显示以下消息:

firebase_admin.exceptions.InvalidArgumentError: Index not defined, add ".indexOn": "Username", for path "/Users", to the rules

Is there something wrong with my code snippet or should I use a different alternative?我的代码片段有问题还是应该使用其他替代方法?

As the error suggests, you need to add ".indexOn": "Username" in your security rules as shown below:正如错误提示的那样,您需要在安全规则中添加".indexOn": "Username" ,如下所示:

{
  "rules": { 
    "Users": {
      ".indexOn": "Username",
      // ... rules
      "$uid": {
        // ... rules
      }
    }
  } 
}

Checkout the documentation for more information.查看文档以获取更多信息。

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

相关问题 如何检查 firebase 数据库中是否存在唯一条目? - How to check if unique entry exists in firebase database or not? 在 React JS 中检查 Firebase 实时数据库中是否存在值 - Check if value exists in Firebase Realtime Database in React JS Python Firebase 如何查看firebase存储上是否存在文件 - Python Firebase How to check whether a file exists on firebase storage 将新属性更新到现有节点 firebase(实时数据库) - update new attribute into exists node firebase(realtime database) 将新属性更新到现有节点 firebase(实时数据库)(编辑) - update new attribute into exists node firebase(realtime database) (edit) 如何在 React Native 中从我的实时 Firebase 数据库中删除单个条目? - How to delete a single entry from my Realtime Firebase database in React Native? 如何从您的 Android 应用程序检查 Firebase 存储中是否存在文件? - How to check if a file exists in Firebase storage from your android application? 实时数据库 - Firebase 不更新 - realtime database - Firebase not updating 如何检查 Firebase/Firestore 中的其他集合中是否存在值 - How to check if value exists in other collection in Firebase/Firestore Firebase 实时数据库规则 - Firebase realtime database rules
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM