Choosing the correct Data Structure in Firebase Firestore for my Flutter Todo App

Viewed 65

I am currently developing a ToDo app with Flutter and Firebase. The initial situation is as follows:

1. the user has to log in when he wants to create ToDos, i.e. the ToDos would have to be saved best under the UID, right?

2. a user can create multiple lists/categories, for this I also thought about the structure and came up with 2 ideas.

First idea: I have 2 collections, one with the UserID and all todos and one with the UserID and all categories.

todo -> title, createdAt, done, category, (link to the second collection with the categories) ...

category -> name, icon, ...

Second idea: I create a single collection per user, the first field is then an array with the name of the category, and in this array are all ToDos.

Unfortunately, I am a complete beginner in Firestore and therefore I am not sure if any of my suggestions would make sense. I hope that the initial situation is well described, otherwise you can still ask questions.

Thank you!

Edit: I just saw a video and I had another idea to create a collection with the UID. This contains all categories as documents and the categories have a subcollection with all Todos.

0 Answers
Related