【发布时间】:2021-08-11 13:55:30
【问题描述】:
我一直在寻找不同的示例,但无法为我的 firebase 节点找到合适的解决方案。我有 3 个节点 1 用于问题,第二个节点包含问题的答案,第三个节点包含对该答案的评论。!
我将如何使用 firebase 执行查询 我一直在寻找不同的示例,但无法为我的火基表找到合适的解决方案。我有 3 个节点
- 问题
- 答案
- 对答案的评论
我将如何使用 firebase 执行查询(基于联接的概念实现)
mdatabaseReference.child("Answer").equalTo(QID);
我将如何获得特定问题的答案以及对该答案的评论!
这是我的 JSON
{
"Answer" : {
"f40357b1-d1f5-4b7a-98ec-54d9e7b2e518" : {
"dateTime" : "16 Mar 2017 15:30:29",
"professorAnswer" : "Hezbollah is an Islamist religious organization founded in 1985 and based in Lebanon. It follows Shi'Islam (also called Shi'ite Islam), the second largest denomination of Islam. Shi'a Muslims follow the teachings of the prophet Muhammad, a direct descendant of Isma'il (the first son of Ibrahim/Abraham).Contd.!",
"professorId" : "7ceef713-eb59-4db4-a8d2-21d5a01eedfc",
"questionId" : "fd2a34a0-e7d9-4b2c-8192-59705df827c2"
}
},
"comment" : {
"29192e3a-a013-4fcc-9859-1f5cc62464cb" : {
"commentText" : "ORGANIZATION hezbollah bases on the bible but their goals is to save people in pagans work!",
"dateTime" : "16 Mar 2017 15:30:52",
"AnswerId" : "f40357b1-d1f5-4b7a-98ec-54d9e7b2e518"
"questionId" : "fd2a34a0-e7d9-4b2c-8192-59705df827c2",
"userId" : "bXCeW6jfidbHuMCCCMkDGWcGZRS2"
}
},
"questions" : {
"41c454a8-fab6-4e41-9093-b1120ffd1be0" : {
"description" : "I know they're a Islamic organization but where are they based? What are their goals?",
"idQuestion" : "fd2a34a0-e7d9-4b2c-8192-59705df827c2",
"time" : "16 Mar 2017 15:30:12",
"title" : "What are the aims of the religious organization Hezbollah?",
"user_id" : "bXCeW6jfidbHuMCCCMkDGWcGZRS2",
}
},
"user" : {
"13bd37e5-fc87-4468-a89e-7cb4ecaab05f" : {
"email" : "email@gmail.com ",
"user_id" : "bXCeW6jfidbHuMCCCMkDGWcGZRS2"
}
}
问题是我想过滤这些事件......例如,使用 .orderByChild("Answer").equalTo(QID) 可能是错误的查询,但它只是为了获取给定问题 ID 的答案然后填充我的列表它。
【问题讨论】:
-
与其用文字描述你的数据结构,不如分享一个 JSON 的代表性 sn-p。您可以通过单击 Firebase Database console 中的导出 JSON 来获取此信息。
-
等待您的回复! @弗兰克·范·普菲伦
标签: android firebase firebase-realtime-database