Firebase规则仅显示vip成员

问题描述 投票:0回答:1

我正在尝试仅为vip用户显示数据。我使用下面的代码,但每个用户都可以看到数据。

我想隐藏普通用户的演员数据并显示vip用户。

"tvshow1": {
          ".indexOn": ["actors"],
            ".read": "data.child('users').child(auth.uid).child('VIP').val() == 'Yes'",
            ".write": "data.child('users').child(auth.uid).child('VIP').val() == 'Yes'"
        },   

数据库结构:

tvshow1

| title:

| date:

| actors:

会员

|id:

   |VIP:
firebase firebase-realtime-database firebase-security-rules
1个回答
1
投票

你需要使用“root”

 ".read": "root.child('users').child(auth.uid).child('VIP').val() == 'Yes'"

写作也一样

© www.soinside.com 2019 - 2024. All rights reserved.