I have a firestore database with two collections: 'notes', where each document stores the content for each note and the authorId (which corresponds to the currently signed in users uid), and 'users', where the name of the user is stored and the id of each document is the uid of the user. This way, the author of the note is connected to the user in firestore. I am trying to make a web application where only the notes that the user created (authorId == uid) are shown and the other notes are not.
I've tried comparing resource.data.authorId and request.resource.data.authorId with request.auth.uid.
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /notes/{note}{
allow read: if request.auth.uid == resource.data.authorId;
}
}
}
I wanted only the notes that the user created to show, but no notes show at all with this rule.