android - 多个数据库的 Firebase 规则
问题描述
我正在使用 Firebase 实时数据库开发一个 Android 应用程序。我的项目包含 3 个不同的数据库:
- 数据库 1:用于常见项目;
- 数据库 2:用于特征 A;
- 数据库 3:用于特征 B;
在数据库 1 中,我可以使用其节点创建规则(为此数据库工作)来验证特定用户是否能够读取和写入任何数据,例如:
{
"rules":
{
"plants":
{
".read": true, /*"auth !== null",*/
".write": "auth !== null && root.child('userRegistration/' + auth.uid).child('profileTypeInfo').val()=='0'"
},
"criteria":
{
".read": "auth !== null",
".write": "auth !== null && root.child('userRegistration/' + auth.uid).child('profileTypeInfo').val()=='0'"
},
"guide":
{
".read": "auth !== null",
".write": "auth !== null && root.child('userRegistration/' + auth.uid).child('profileTypeInfo').val()=='0'"
},
"userRegistration":
{
".read": true,
".write": true
},
"report" :
{
".read": "auth !== null && root.child('userRegistration/' + auth.uid).child('isActiveInfo').val()==true",
".write": "auth !== null && root.child('userRegistration/' + auth.uid).child('isActiveInfo').val()==true",
}
}
}
对于这个数据库是可以的,因为我使用的是当前数据库的root.child。这个问题与数据库 A 和 B 有关,因为我想使用这样的东西:
database1.child('userRegistration/' + auth.uid).child('profileTypeInfo').val()=='0'"
而不是使用
root.child('userRegistration/' + auth.uid).child('profileTypeInfo').val()=='0'"
换句话说,我需要使用数据库 1中的子数据,尽管使用了不包含子userRegistration的根子
我非常感谢您的帮助!
解决方案
推荐阅读
- stanford-nlp - 如何使用 Stanford CoreNLP OpenIE 在单独的文件中获得输出?
- reactjs - NormalModuleReplacementPlugin 无法用资产中的另一个 scss 文件替换 node_modules scss 文件
- c++ - 如何在 iOS Xcode 项目中编译 C++ 库(包括其依赖项)?
- mysql - 如何将这三张表合并为一张表
- amazon-web-services - AWS CLI:创建 EC2 实例并附加实例配置文件(未经授权)
- java - 如何将 Jfoenix 与 eclipse 集成
- javascript - 从 API 响应创建函数
- reactjs - Swiperjs。如何将自定义道具传递给 SwiperSlide 并获取它的 onSlideChange 函数?
- kubernetes - 对于相同的关键操作,etcd 和 PV 存储在 GKE 中的不同行为
- progressive-web-apps - 更新问题,Service Worker