I\'m currently creating an e-commerce app for iOS and I\'m having trouble deciding on how to structure my database for the scenario of a user searching for an item by \"keywords
How about:
items
item0
color: black
type: t-shirt
option: design
keywords: black_t-shirt_design
item1
color: black
type: hat
option: design
keywords: black_hat_design
then a simple query using startingAt and endingAt.
So for example, say the user is using a filter to narrow the results and wants to know about all of the black hats and doesn't care what the option parameter is:
itemsRef.queryOrdered(byChild: "keywords")
.queryStarting(atValue: "black_hat")
.queryEnding(atValue: "black_hat")
likewise if the user wanted to know about all of the clothing that's just black, you could query on the 'color' child for black.
But if they wanted all of the black hats with the design option
itemsRef.queryOrdered(byChild: "keywords")
.queryStarting(atValue: "black_hat_design")
.queryEnding(atValue: "black_hat_design")