DEV Community

lambnoah99
lambnoah99

Posted on

Need Help with Data Modelling in Firebase

I'm trying to create a Data Structure in Firebase for a group todo app like this:

Users-Collection: Every user is a document with some attributes, a user can be part of many groups (1 -> n).

Groups-Collection: Every group is a document with attributes, a group has many users (1 -> n), a group has many items (1 -> n).

Todos-Collection: Every todo is a document with a ID and some attributes.

My Question is what the best way would be to model this? While developing I discovered, that if i want to display all of a groups users, i had to make a request for every user, or i had to store every attribute of a user inside the group's document. And the same would apply to the Todos.

Here are some screenshots how the Data Structure is looking right now:
Users-Collection:
Alt Text

Groups-Collection:
Alt Text

Btw for Frontend I'm using Ionic 4 with Angular and for firebase interactions I use AngularFire.

Top comments (0)