java - Firebase 数据检索 java

标签 java firebase firebase-realtime-database

{
    "Account1" : 
    {
        Push_key(): { Carplate: "ABC1234" }
        Push_key(): { Carplate: "ABC" }
        Push_key(): { Carplate: "A" }
    }
}

这是数据库的样子。 我想检索仅包含 "A" 的第三个数据。 我正在使用 startAt()endAt() 进行数据检索:

Query query = ref.child("Account1").orderByChild("Carplate").startAt("A").endAt("A"+"\uf8ff");

但它返回所有 3 条记录。 (我认为这是因为它们都是从 “A” 开始的。) 需要帮忙!请!

最佳答案

你应该看看 equalTo() 方法(来自 doc ):

The equalTo() method allows you to filter based on exact matches. As is the case with the other range queries, it will fire for each matching child node.

要使其适应您的查询,您可以尝试:

Query query = ref.child("Account1").orderByChild("Carplate").equalTo("A");

关于java - Firebase 数据检索 java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49144601/

相关文章:

java - 在 Google App Engine 中每 n 秒运行一个 java 函数

java - 将 httpheaders 的映射添加到构建器

java - 以编程方式识别 Tomcat 启动

java - 无法在 Hashmap 中保存 block

excel - 从 Excel 中的客户端应用程序导出 Firestore 数据

android - 如何在 firebase android 中获得特定的值(value)?

java - 如何从 Firebase Realtime DB 获取两个变量

firebase - 在 github 操作上运行 firebase 模拟器

javascript - 带有 firebase 的 Google Polymer : timing

javascript - Firebase 规则保护自动增量计数器?