Refactor Firestore Documents to Use Sub-collections #155
Labels
backend
Task must have a back end issue
debt
Tasks to resolve technical debts and/or increase maintainability
difficulty::medium
Challenging tasks
Context
Originally the user document contained a user's visits and contacts in an array. The intent was that this would reduce document reads (and therefore costs) for the firestore. This makes enforcing security rules for visits and contacts difficult as Firestore's security rules are not designed to work with large arrays.
Proposed Solution
Use sub-collections for the user document to store visits and contacts. This allows us to design security rules and data validation for each document in the sub-collection. Note that this may several refactors throughout the application to transition from the existing system.
Alternative solutions
There are two other ways to structure the firestore:
Additional Notes
This blocks #145
The text was updated successfully, but these errors were encountered: