So, I have a product saved to my Firestore DB, but I havent figure out how I can manage product addons, for example lets say the item was a pizza, and the person wanted extra cheese or extra tomatoes. Im not sure the best way to map this info in my DB. Lets say the following is my product entry (removed things like added timestamps for simplicities sake)
{
itemName (String)
itemBasePrice (number)
itemStock (number)
availableAt (array (of stores))
}
What is the best way for me to map product addons like extra cheese, or pepperoni, etc. should I make a DB entry for each addon? I feel like its expensive to make 100 calls from the DB to add one item to your basket?
Based on the description you provided, I think for this use case, nested fields or arrays should be the best option. I suggest you refer to this documentation and blog on how to structure data and use of arrays. If there is more information that needs to be tracked for each add ons, then you can consider using sub-collections. There are pros and cons for each way to structure the data. It really depends on how you are planning to use/query the data.