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