Typescript 是否可以通过这种方式获取此数据库结构的数据?

Typescript 是否可以通过这种方式获取此数据库结构的数据?,typescript,firebase,firebase-realtime-database,angularfire2,Typescript,Firebase,Firebase Realtime Database,Angularfire2,我有一个这样的结构: "games" : { "03e46939-af4e-4b9a-ba3b-99132f0bf34d" : { "1P0mWbp1jYOayaMEyQcnKvX4YB63" : { "logs" : { "-LDxpYtVZJc4LmJmyzn1" : { "guess" : "1234", "result" : "1P 1B", "score" :

我有一个这样的结构:

"games" : {
    "03e46939-af4e-4b9a-ba3b-99132f0bf34d" : {
      "1P0mWbp1jYOayaMEyQcnKvX4YB63" : {
        "logs" : {
          "-LDxpYtVZJc4LmJmyzn1" : {
            "guess" : "1234",
            "result" : "1P 1B",
            "score" : 150
          }
        },
        "maxbulls" : 1,
        "maxpigs" : 1,
        "moves" : 1,
        "profilepicture" : "bull.png",
        "score" : 150,
        "username" : "user1p0mw"
      },
      "5AvSPiyH3faqw1P7inHdyjV6noC2" : {
        "maxbulls" : 0,
        "maxpigs" : 0,
        "moves" : 0,
        "profilepicture" : "pig.png",
        "score" : 0,
        "username" : "user5avsp"
      },
      "answer" : "8103e4693964",
      "id" : "03e46939-af4e-4b9a-ba3b-99132f0bf34d",
      "requestor" : "1P0mWbp1jYOayaMEyQcnKvX4YB63",
      "status" : "pending",
      "turn" : ""
    },
    "21b1451-rf45-4b9a-ba3b-99132fgoe856" : {
      "5AvSPiyH3faqw1P7inHdyjV6noC2" : {
        "logs" : {
          "-LSwzYtVZJp9s6gmuw7n" : {
            "guess" : "1234",
            "result" : "1P 1B",
            "score" : 150
          }
        },
        "maxbulls" : 1,
        "maxpigs" : 1,
        "moves" : 1,
        "profilepicture" : "pig.png",
        "score" : 150,
        "username" : "user5avsp"
      },
      "answer" : "8103e4693964",
      "id" : "21b1451-rf45-4b9a-ba3b-99132fgoe856",
      "requestor" : "5AvSPiyH3faqw1P7inHdyjV6noC2",
      "status" : "pending",
      "turn" : ""
    }
  }
其中有许多游戏具有独特的guid,并且包含1-2个uid的键。我想得到所有游戏,其中
5AvSPiyH3faqw1P7inHdyjV6noC2
是一个游戏的孩子。查询时,我不知道游戏ID

我尝试了
this.afDatabase.list('/games/',ref=>ref.orderByChild(user.uid))
,结果所有游戏都被拉入编辑:无论传入什么UID。我意识到这个例子不好,因为在这种情况下,我希望所有游戏都返回。

this.afDatabase.list('/games/',ref=>ref.orderByChild(user.uid).equalTo(user.uid))
,它不包含任何游戏


this.afDatabase.list('/games/',ref=>ref.orderByChild().equalTo(user.uid))
这会引发一个关于没有传入任何参数的
orderByChild
的错误。

当前结构允许您有效地检索给定游戏中的子节点(看起来像uid)。它不允许您有效地检索给定UID的游戏。为此,考虑添加一个逆结构<代码> /用户/$uID/$GAMIDID < /代码>。另请参阅@FrankvanPuffelen抱歉,回复时间太长。我有一个页面,列出了给定UID的所有游戏。该页面还显示游戏的一些属性,如状态和对手档案图片。如果我在游戏中的每个用户上维护一个游戏ID列表,我是否需要复制所有使用过的游戏信息?或者有没有一种简单的方法来获取游戏ID列表并获取每个游戏对象?是的。在NoSQL数据库中,复制非常常见。如果您来自关系数据库的背景,可能需要一些时间才能习惯。我推荐阅读和观看。