function isWriter(request,resource) {
return ('writerIds' in resource.data) && resource.data.writerIds == request.auth.uid;
}
match /bookmarks/{bookmarks} {
allow read: if isWriter(request,resource)
}
In my bookmark collection, When I put the accessible writer's id into writerIds key then this rules fails but if i change the key to studentId and change the rule into below mentioned way, then it works
function isWriter(request,resource) {
return ('studentId' in resource.data) && resource.data.studentId == request.auth.uid;
}
match /bookmarks/{bookmarks} {
allow read: if isWriter(request,resource)
}
The only differnece between both the keys is that studentId is a composite index but writerIds is not.
My Document looks like
{isBookmark:boolean, studentId:string, writerIds:string}
I have also tried with the partial conditions as well by changing the isWriter Function to this for both studentId and writerIds but this behaves same as above.
function isWriter(request,resource) {return ('writerIds' in resource.data)}
Is it possible that resource object only access the keys which are composite index?