【问题标题】:Firebase database is being updated at one node but is not affecting the other nodeFirebase 数据库正在一个节点上更新,但不影响另一个节点
【发布时间】:2016-10-20 05:27:48
【问题描述】:

我有两个兄弟姐妹,即“意图”和“消息”。当我更新消息字段时,它会正确完成,但是使用意图字段完成相同的过程,不会发生任何变化。下面是相同的 android-java 代码。

    IntentMessage testIntentMessage = new IntentMessage("Hello test intent", "Hello test intent");
    FriendlyMessage tempMessage = new FriendlyMessage("namastey", "india", "http://imgsdown.1mobile.com/group1/M00/C1/21/S36rZla-KYqAV08jAABUIgbzI-E596.png","543587653");
    mFirebaseDatabaseReference.child("intents").child("-sjhfdvshv").setValue(testIntentMessage);
    mFirebaseDatabaseReference.child("messages").child("-KUVR-MkLOVwNkx6nm-_").setValue(tempMessage);

以下是执行上述命令后我的 Firebase 数据库 JSON 文件:

{
  "intents" : {
    "-kjuvhsjkv" : {
      "intentFields" : "testIntentFields 1",
      "intentName" : "testIntentName 2"
    },
    "-sjhfdvshv" : {
      "intentFields" : "testIntentFields",
      "intentName" : "testIntentName"
    }
  },
  "messages" : {
    "-KUVR-MkLOVwNkx6nm-_" : {
      "name" : "india",
      "photoUrl" : "http://imgsdown.1mobile.com/group1/M00/C1/21/S36rZla-KYqAV08jAABUIgbzI-E596.png",
      "text" : "namastey",
      "timeStamp" : "543587653"
    }
  }
}
}

真正的问题是: 当“消息”节点一切正常时,为什么“意图”节点没有更新? 鉴于我以与 FriendlyMessage 类相同的方式制作了 IntentMessage

【问题讨论】:

  • 可能是数据库规则的原因,请贴出来。还要检查logcat,如果setValue有问题,firebase会在logcat中打印警告信息。
  • 是的@Wilik先生,你说得对,我没有在firebase的“规则”部分提到“意图”的规则。现在我正在接收数据。非常感谢。
  • 欢迎您@Aakash Bansal,顺便说一句,请接受您自己的答案。 :D

标签: android firebase firebase-realtime-database


【解决方案1】:

正如 Wilik 所说,我遇到了我的问题,我没有在数据库的“规则”部分中提到“意图”部分的规则。现在我得到了正确的数据。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-12-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-02
    • 2023-02-18
    • 2022-01-23
    相关资源
    最近更新 更多