我正在尝试将Firebase的Rule通配符与子项比较混合使用.
我正在读一个价值为'4'的孩子.
当我进行文字比较时,模拟器会给我绿灯(如下所示):
{
"rules": {
"die": {
"rolls": {
"$i": {
".read": "4 == root.child('die/i').val()"
}
},
"i": {
".read": true,
".write": true
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
输出(成功):
Type read
Location /die/rolls/4
Data null
Auth null
Read successful
Line 7 (/die/rolls/4)
read: "4 == root.child('die/i').val()"
Run Code Online (Sandbox Code Playgroud)
但是通配符比较失败了.为什么?
{
"rules": {
"die": {
"rolls": {
"$i": {
".read": "$i == root.child('die/i').val()"
}
},
"i": {
".read": true,
".write": true
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
输出(失败):
Type read
Location /die/rolls/4
Data null
Auth …Run Code Online (Sandbox Code Playgroud) real-time wildcard firebase firebase-realtime-database firebase-security-rules