Sample collection of users
.
"users":{
"uid1":{
"type":"normal"
},
"uid2":{
"type":"normal"
},
"uid3":{
"type":"admin"
},
"uid4":{
"type":"super-admin"
},
"uid5":{
"type":"disabled"
}
}
Sample rules.
"rules":{
"users":{ // I dont want the collection to be readable to everyone
"$uid":{
".read":"auth.uid == $uid",
".write":"auth.uid == $uid"
}
}
}
Sample query.
firebase.database()
.ref('users')
.orderByChild('type')
.equalTo('normal')
.once('value')
.then()
.catch()
This query however returns a Permission denied
error on path /users
. How do I make the base collection secure but still the children are readable via orderByChild()
?