0

Please consider the following data structure in firebase:

products
  + p1
    +name
    +tags
      +t1
      +t2
  + p2 (similar to p1 above)
tags
  +t1
    +p1 (p1 is the product-id) 
    +p2
  +t2
    p3
    p1
  +t3
    p4
    p2

I understand that if I wanted to query products by tag - the above structure would be useful (ref /tags/$tag) will get me the list of the products.

However, how do I implement / query for intersection of two or more tags? I am open to modifying the data structure to the do this in the best way.

So what I really want to query (and therefore store data) for is the query

get products that match tags 1, tags 2 and tags 3 

Would I need to "run my own server" to do this? Is it possible to automatically aggregate data in Firebase

Community
  • 1
  • 1
Mayank R Jain
  • 3,127
  • 1
  • 29
  • 43
  • 1
    There is no method for automatically aggregating data. You would perform a separate query based on each tag and join the results by hand. – Kato Feb 19 '15 at 17:51
  • Thanks @Kato! So just read the last X list from each part and manually filter / sort it in js! Is there a recommended "aggregation" / sort /filter js lib that works well with firebase or processing like these? – Mayank R Jain Feb 21 '15 at 02:52
  • 1
    Firebase-util works fairly adequately. It will have a new release within the month which will be a great deal more effective. – Kato Feb 21 '15 at 15:48

1 Answers1

0

Please wait some more time as Client side joining and and intersection are introduced in the Firebase Developer Summit 2016, it's documentations and tutorials will be available soon.