【发布时间】:2016-03-26 18:06:14
【问题描述】:
鉴于以下数据结构(从 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 中查询嵌套数据的正确方法?
【问题讨论】:
标签: javascript json firebase