将firebase数据库的所有实例或多个侦听器的最佳实践更改为单个节点

时间:2017-09-01 00:22:23

标签: firebase firebase-realtime-database

在这样的示例firebase数据库结构中,

{
  "posts": {
 "-JRHTHaIs-jNPLXOQivY": {
  "uid": "0OBRNR61rDagBx6cXmLqVGkBpTZ4",
  "photoURL": "XXXXXXXXXXX",
  "displayName": "John Smith",
  "message": "Hello my name is John Smith"
},
"-JRHTHaKuITFIhnj02kE": {
   "uid": "13qChHOh4eWu0wb8Bb54P3DlnTU5",
  "photoURL": "YYYYYYYYYY",
  "displayName": "Jenny Johnson",
  "message": "Hello my name is Jenny Johnson"
},
"-JRGUKnCuPTFYknj0opx": {
  "uid": "13qChHOh4eWu0wb8Bb54P3DlnTU5",
  "photoURL": "YYYYYYYYYY",
  "displayName": "Jenny Johnson",
  "message": "Hey Whats Up"
},
"-JROHHaIs-jNTOZOCjtZ": {
  "uid": "0OBRNR61rDagBx6cXmLqVGkBpTZ4",
  "photoURL": "XXXXXXXXXXX",
  "displayName": "John Smith",
  "message": "Doing well thanks"
 },
},
 "Users": {
"0OBRNR61rDagBx6cXmLqVGkBpTZ4":{
    "displayName": "John Smith",
    "photoURL": "XXXXXXXXXXX" 
},
"13qChHOh4eWu0wb8Bb54P3DlnTU5":{
    "displayName": "Jenny Johnson",
    "photoURL": "YYYYYYYYYY" 
 }
}

如果我更改了“John Smith”或“photoURL”的displayName,那么在那些可以对齐的所有帖子中更改这些属性的最佳方法是什么? (即,最初由John Smith根据uid发布的所有帖子将更改为...如果我将用户/ 0OBRNR61rDagBx6cXmLqVGkBpTZ4的displayName更改为Bob Smith,则说明Bob Smith)

或者,最好的方法是将每个帖子的引用包含在其uid的displayName和photoURL中吗?

0 个答案:

没有答案