I'm building a social media app using Firebase and I want each user to have a unique username that can be later changed to something else like Instagram etc.
How can I set up a security rule for Cloud Firestore to prevent a WRITE operation when the incoming "username" data already exist in another document
User Collection Data Structure
- documentID = user.uid (from Firebase Auth)
- username
- first_name
- last_name