I have a list of products, e.g.
Name
ImageURL
Type
Description
Imagine I wanted to do the following query in an iOS app:
- Determine how many unique types of product are in the list and present 5 items at random from each type.
E.g.
Type A
- 0
- 1
- 2
- 3
- 4
Type B
- 5
- 6
- 7
- 8
- 9
What would be the best way to set up a Firebase Cloud Firestore db to support this?
I was thinking to pre-process the list so do the following
Collection
- Document (TypeA)
- Collection (Product1)
- Collection (Product2)
- Collection (Product3)
- Collection (Product4)
- Collection (Product5)
- Document (TypeB)
- Collection (Product6)
- Collection (Product7)
- Collection (Product8)
- Collection (Product8)
- Collection (Product9)
but then I'm not sure how the query would work?
E.g.
db.collection("Products").getDocuments().getCollections().limit(to: 5)