In Firestore I have 2 collections
A users collection and a periods collection. I need a rule for my period collection : Read and write only by the user who create the period.
This is what I try with no success
service cloud.firestore {
match /databases/{database}/documents {
function userDoc() {
return /databases/$(database)/documents/users/$(request.auth.uid);
}
match /users/{userId} {
allow read: if true;
allow create, update: if request.auth.uid == userId;
}
match /periods/{id} {
allow read : if userDoc() == request.resource.data.user;
allow write : if userDoc() == request.resource.data.user;
}
}
}

