Let's say I am building an application where users can send emails. The emails are in one of three states/folders:
- Draft/Drafts
- Sending (waiting to be sent by the server)/Outbox
- Sent
Which of these approaches would be the most efficient (least resource intensive) and which one would be the preferred design in most use cases to store the emails in a Firestore database?
- There is an
emailscollection, inside of which aredrafts,outbox, andsentsub-collections. As an email progresses through the three stages of progress the document is moved between each collection. - The same concept as approach 1 however, each of the three sub-collections are root collections rather than sub-collections of an
emailscollection. - There is an
emailscollection with all the documents from each state at the root of the collection. Each document has astatusfield/property which is set to eitherdraft,sending, orsent.