问题描述
{
"rules": {
".read": false,".write": false,"devices": {
".read": "auth.uid != null && query.orderByChild == 'ownerUid' && query.equalTo == auth.uid","$device": {
".read": "data.child('ownerUid').val() == auth.uid","nickname": {
".write": "data.parent().child('ownerUid').val() == auth.uid",".validate": "newData.isstring() && newData.val().length < 30"
},"ownerUid": {
".validate": "root.hasChild('users/' + newData.val())"
},... additional fields here
}
}
}
}
在我的网络应用程序中,使用 reactfire
和 firebase
npm 模块,我查询了如下设备:
const devicesRef = useDatabase()
.ref(`devices`)
.orderByChild('ownerUid')
.equalTo(user.uid);
const { data: devices,status } = useDatabaseListData<Device>(devicesRef,{ idField: 'id' });
这似乎有效,但如果我查看网络选项卡,我可以看到所有数据都返回,而不仅仅是应该返回的数据。返回给我的代码的数据是我期望的数据。
请注意,在下面的屏幕截图中,所有 数据都会返回,即使是没有定义 ownerUid 的数据。
我几乎完全使用文档中的示例:https://firebase.google.com/docs/database/security/rules-conditions#query-based_rules
我做错了吗?或者这是 Firebase 中的错误?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)