所以我试图在这个结构中找到数据“aaaaabbbbbbaaaa”: disney studentList -Jh46tlaNFx_YmgA8iMJ: "aaaaabbbbbbaaaa" -Jh474kAvoekE4hC7W3b:"54ce1cbec4335cd3186105dc" 我用过这个 var ref = new Firebase("https://disney.firebase
disney studentList -Jh46tlaNFx_YmgA8iMJ: "aaaaabbbbbbaaaa" -Jh474kAvoekE4hC7W3b:"54ce1cbec4335cd3186105dc"
我用过这个
var ref = new Firebase("https://disney.firebaseio.com/");
ref.child("studentList").orderByKey().equalTo("54ca2c11d1afc1612871624a").on("child_added", function(snapshot) {
console.log(snapshot.val());
});
但我没有得到任何回报.哪里错了?
我该怎么用?
你的钥匙是-Jh46tlaNFx_YmgA8iMJ和-Jh474kAvoekE4hC7W3b.您可以通过以下方式轻松确定:
ref.child("studentList").orderByKey().on("child_added", function(snapshot) {
console.log(snapshot.key()); // on newer SDKs, this may be snapshot.key
});
您似乎希望按其值对节点进行排序,但这不是Firebase目前可用的操作. Firebase只能是query children by a value of a named property,key或priority.因此,如果您将数据结构更改为:
disney
studentList
-Jh46tlaNFx_YmgA8iMJ:
name: "aaaaabbbbbbaaaa"
-Jh474kAvoekE4hC7W3b:
name: "54ce1cbec4335cd3186105dc"
您可以通过名称获取子订单:
ref.child("studentList")
.orderByChild("name")
.equalTo("54ca2c11d1afc1612871624a")
.on("child_added", function(snapshot) {
console.log(snapshot.val());
});
只是一个侧节点:如果您的实际节点值与您提供的示例中的节点值类似,您可能需要考虑使用这些值作为键;他们看起来对我未经训练的眼睛来说已经非常独特.
