簡體   English   中英

在firebase中查詢深度嵌套的孩子

[英]querying deeply nested children in firebase

鑒於以下數據結構(從firebase導出):

{
"users" : {
  "123456789" : {
    "email" : "test@gmail.com",
    "name" : "test",
       "listings" : {
          "adtitle" : {
            "description" : "this is a description",
            "skilltype" : "painter"
          },
          "adtitle2" : {
            "description" : "this is a second description",
            "skilltype" : "painter"
          }
       }
    }
  }
}

我想運行以下查詢:

var ref = new Firebase("https://my.firebaseio.com/users");
ref.orderByChild("listings/adtitle/skilltype").equalTo("painter").on("child_added", function(snapshot) {
    console.log(snapshot.key());
});

但是在控制台上出現以下錯誤:

Error: Query.orderByChild failed: First argument was an invalid key: "listings/adtitle/skilltype".  Firebase keys must be non-empty strings and can't contain ".", "#", "$", "/", "[", or "]").

誰能看到我要去哪里錯了? 我認為這是在Firebase中查詢嵌套數據的正確方法?

Firebase JavaScript SDK 2.3中引入了查詢更深層屬性的功能。 如果您以Android或iOS為目標,則該功能是在這些SDK的2.4版中引入的。

確保您使用的是該版本(或更新的版本)。

請注意,我不認為這是一個答案,但是這個問題反復出現(請參閱昨天的內容 ),沒有答案,我就無法標記重復項。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM