【发布时间】:2015-09-11 15:25:24
【问题描述】:
我试图弄清楚如何根据 Firebase 中的子子节点过滤产品。
我的设置如下:
products/
product1
/author: 12345
/title: "Awesome"
/description: "more awesome"
product2
/author: 67890
/title: "Awesome"
/description: "more awesome"
如何查询 Firebase 以便仅检索它所持有的 child($productId).child(author) 等于 12345 的产品?
我尝试了以下方法,但这显然不起作用。我需要一种方法来过滤子子项:
var ref = new Firebase(FBURL);
// Attach an asynchronous callback to read the data at our posts reference
ref.child("products").child('$productId').child('author').equalTo(12345).on("value", function(snapshot) {
console.log(snapshot.val());
}, function (errorObject) {
console.log("The read failed: " + errorObject.code);
});
【问题讨论】:
-
目前在 Firebase 中无法按较低级别的子项进行排序/过滤。见stackoverflow.com/questions/27207059/…
-
我最初误解了你的问题。可以过滤子节点的属性。在下面回答。
标签: javascript angularjs firebase nosql