I have a noSQL db with products. These products obviously have some characteristics and I can filter the products out by their properties.
How does this work with tags? More specifically, how should I structure the nodes such that I can filter out items with a specific tag?
Firebase
Follow up if you are familiar with Firebase .equalTo(): how would I structure my FB db and how would I query out items with a specic tag?
One thing I was thinking of is to have seperate properties for the nodes, e.g.:
$productId
/tag_1
/tag_2
But then I have to filter or query multiple times. How can this be overcome or are there other ways?
You're putting the
tags
underneath theproducts
. Try flipping it.Now you can find a product by a tag without a query.
The JSON would look like this:
Rather than true you could store any other relevant information. But having the
$productId
as the key you can easily retrieve a product by it's tag.