In my Fitness app by now I have only one collection users
where every user has his own document. And in this document is stored all of the data from one user. Now I want to create a new collection plans
so that every plan has his own document too. How can I handle it that the plans are saved by the right user? Because now the plan isnt saved anymore in the user document. Or is this the false way of data modeling?
class FireBaseHandler {
Future is_user_registered(String email) {
return FirebaseFirestore.instance
.collection('users')
.where('email', isEqualTo: email)
.get();
}
Future register_new_user(email, password) {
print(email + "->" + password);
return FirebaseFirestore.instance.collection("users").doc(email).set(
{
"email": email,
"password": password,
"token": -1,
"plans": [],
},
);
}