I am currently facing a challenge in filtering products based on their sub child nodes within Firebase.
This is how my data is structured:
products/
product1
/author: 12345
/title: "Awesome"
/description: "more awesome"
product2
/author: 67890
/title: "Awesome"
/description: "more awesome"
Is there a way to query Firebase in order to retrieve only the products where it's found that child($productId).child(author)
matches 12345
?
I attempted the code below, but as expected, it didn't yield the desired results. I need guidance on how to effectively filter based on the subchild criterion:
var ref = new Firebase(FBURL);
// Set up an event listener for changes at the specified location
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);
});