简体   繁体   中英

firestore security rules syntax for

what is the syntax for using the auth.uid as item path in firestore

in firebase it would be this:

data.child(auth.uid).val() == 'admin'

I tried in firestore this, but is not working

resource.data.request.auth.uid == 'admin'

thans

resource.data is an object containing the data of document being read/written. If you are trying to read values of a field in that document then try:

allow read: if resource.data[request.auth.uid] == 'admin'

This rule will allow read operation if the field request.auth.uid is admin .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM