[英]Firebase realtime database rule - auth
if my data structure is like the following (example: an array of books)如果我的数据结构如下所示(例如:一系列书籍)
books:
0 : name = book1,
id= 123
1: name = book2,
id = 456
2: name = book3,
id = 789
how can I grant read and write access in firebase realtime database for the '/books' url?我如何在 firebase 实时数据库中授予 '/books' url 的读写权限? Please note that my 'auth.id' matches the 'id' inside each book.
请注意,我的“auth.id”与每本书中的“id”相匹配。
so the data is (books/0/id == auth.id) but the url access to read and write is for '/books'.所以数据是 (books/0/id == auth.id) 但 url 读写权限是针对 '/books' 的。 Is there a way to use the id and grant access at a parent level?
有没有办法在父级别使用 id 和授予访问权限?
I tried the following,我尝试了以下,
"rules"
"books"
"$id" {".read" : $id == auth.uid}
but no luck..但没有运气..
Thanks谢谢
Since you are working with arrays, I guess that $id
captures just the index.由于您正在使用 arrays,我猜
$id
只捕获索引。 So, you'd try the following:因此,您将尝试以下操作:
{
"rules": {
"books": {
"$book_index": {
".read" : "data.child('id').val() == auth.uid"
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.