currenty when somebody registers in my app, im providing an Input field which returns if the entered username already exists in the database.
Future getUserName(String userNameFieldInput) {
print('userNameFieldInput: $userNameFieldInput');
return FirebaseFirestore.instance
.collection('usernames')
.doc(userNameFieldInput)
.get()
.then((value) => value.exists ? true : false)
.catchError((error) => print(error));
}
Im returning true or false and thats totally fine. Im not sure if my database structure is fine for that. I would love to have some recommendations on here. Also how many reads do we have here? IM using the Firestore.
MyDatabase
|
---Users
| |
| ---THE_USERS_UID
| |
| |--name: "marcel"
| |
| |---gender: "male"
| |...
|
---usernames
|
---marcel
|
|---uid: "THE_USERS_UID"