Firebase Realtime数据库中的深度查询

时间:2019-12-17 05:40:04

标签: javascript firebase-realtime-database

在Firebase实时数据库中考虑以下Json结构

"reports": {
  "-LsqM6BMBcbpSurPUQI7": {
    "reportedTo": {
      "L1": {
        "-LwDyYzua6MN1biKVSSk": {
          "timestamp": 1576504280133,
          "user": "TdmqmdWUKATcCYsjWH12SZek87j1"
        },
        "-LwDyZ3a2bCvWKqK2FAP": {
          "timestamp": 1576504280633,
          "user": "s4GJ42t1zdbur48OQwzMgrn2p4B2"
        }
      },
      "L2": {
        "-LwE4QRrvmhhkkMKnu1f": {
          "timestamp": 1576506079146,
          "user": "DdZgodGjFOg2fNPJPKPT9wcqa2G3"
        },
        "-LwE4QY4ctY7SV_q-gIC": {
          "timestamp": 1576506079445,
          "user": "uBzlslel6lPVmf1JWWLW7XjoAd63"
        }
      },
      "L3": {
        "-LwEBHeDTDE9jW89xEQs": {
          "timestamp": 1576507878046,
          "user": "vilGHQlpSPUQ77hnLr5OzmsrGTz1"
        },
        "-LwEBHeDTDE9jW89xEQt": {
          "timestamp": 1576507878046,
          "user": "vilGHQlpSPUQ77hnLr5OzmsrGTz1"
        }
      }
    },
  },
  "-LsqM94G-y5T6WAIfvJh": {
    ...something similar to above
  }
}

基本上,这是一份报告数据库。我想获取报告给特定用户的报告列表,例如“ DdZgodGjFOg2fNPJPKPT9wcqa2G3”。

据我对文档的理解,这似乎很困难。是否可以跳过2个级别的唯一ID?在这种情况下。

0 个答案:

没有答案