{
"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/