I have tried to understand how to structure data in Firebase, but I'm struggling to apply the examples to what I have, some advice would be great. Image of Database Structure
I have a list of portfolios. Each portfolio has a name and its own key (probably bad practice, but I couldn't work out how to get the key easily in my JS).
I have a list of orders. Each order has a name and portfolio attribute set to the key of the portfolio it belongs to.
- Do I have to store order ID's in my portfolio?
- How do I get a list of orders where order.portfolio equals portfolio.key?
I've tried to use equalTo, however I don't think I'm using it correctly.
firebase.database().ref("orders").orderByChild("portfolio").equalTo(thisref.portfolio.key).on('value', function(snapshot) {
var orders = snapshot.val();
});