I have a problem with Firestore rules. I wish to enforce username uniqueness upon creation, I have the following rules:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read;
}
match /staff/{staff} {
allow create: if !exists(/databases/$(database)/documents/staff/request.resource.data.username);
}
}
}
They seem to be allowing everything even if the username is the same as one in the database.