javascript - Best Practice Data Relationships and Selecting with Firebase -


i have tried understand how structure data in firebase, i'm struggling apply examples have, advice great. image of database structure

i have list of portfolios. each portfolio has name , own key (probably bad practice, couldn't work out how key in js).

i have list of orders. each order has name , portfolio attribute set key of portfolio belongs to.

  1. do have store order id's in portfolio?
  2. how list of orders order.portfolio equals portfolio.key?

i've tried use equalto, don't think i'm using correctly.

    firebase.database().ref("orders").orderbychild("portfolio").equalto(thisref.portfolio.key).on('value',  function(snapshot) {       var orders = snapshot.val();     }); 

see answer related question here: what's best way of structuring data on firebase?

i'm practical terms download data local "store" , "join" data need based on i'd on record. so

  1. yes
  2. download both sets on app initiation , use loop or lodash filter orders given portfolio

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -