Firebase rules for multiple databses
up vote
2
down vote
favorite
I'm developing an Android app using Firebase Realtime Database.
My project contains 3 distinct databases:
- Database 1: for common items;
- Database 2: for feature A;
- Database 3: for feature B;
In database 1, I'm able to create rules (working for this database) using its nodes to validate if specific user is able to read and write any data, for instance:
{
"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",
}
}
}
For this Database is OK, because I'm using the root.child of the current database. The issue is related to database A and B, because I'd like to use something like this:
database1.child('userRegistration/' + auth.uid).child('profileTypeInfo').val()=='0'"
instead of using
root.child('userRegistration/' + auth.uid).child('profileTypeInfo').val()=='0'"
In other words, I need using the child data from the database 1 despite of using the root child, which not contains the child userRegistration
I do appreciate your help!
android firebase firebase-realtime-database
add a comment |
up vote
2
down vote
favorite
I'm developing an Android app using Firebase Realtime Database.
My project contains 3 distinct databases:
- Database 1: for common items;
- Database 2: for feature A;
- Database 3: for feature B;
In database 1, I'm able to create rules (working for this database) using its nodes to validate if specific user is able to read and write any data, for instance:
{
"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",
}
}
}
For this Database is OK, because I'm using the root.child of the current database. The issue is related to database A and B, because I'd like to use something like this:
database1.child('userRegistration/' + auth.uid).child('profileTypeInfo').val()=='0'"
instead of using
root.child('userRegistration/' + auth.uid).child('profileTypeInfo').val()=='0'"
In other words, I need using the child data from the database 1 despite of using the root child, which not contains the child userRegistration
I do appreciate your help!
android firebase firebase-realtime-database
why did you cut your database in 3 ? I'm not seeing any way to have global rules in firebase right now
– mcfly
Nov 11 at 14:48
1
Hi @mcfly, in my scope I do need separate in multiple data base due to different versions. If I use just one (as previously) I would do lof of stuff through java. I know how to do it via java but via Firebase rules are more reliable, I mean, I would spent to much effort do to the same in java
– Gláucio Leonardo Sant'ana
Nov 11 at 15:11
1
what about put your old version data into a sub collection and keep having only one databse ?
– mcfly
Nov 11 at 15:18
You're right! That would be a great possibility such as: Root (being able to use the rules easily) Subcollection 1 SubCollection 2 SubCollection 3
– Gláucio Leonardo Sant'ana
Nov 11 at 15:20
Glad it helps :)
– mcfly
Nov 11 at 15:38
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I'm developing an Android app using Firebase Realtime Database.
My project contains 3 distinct databases:
- Database 1: for common items;
- Database 2: for feature A;
- Database 3: for feature B;
In database 1, I'm able to create rules (working for this database) using its nodes to validate if specific user is able to read and write any data, for instance:
{
"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",
}
}
}
For this Database is OK, because I'm using the root.child of the current database. The issue is related to database A and B, because I'd like to use something like this:
database1.child('userRegistration/' + auth.uid).child('profileTypeInfo').val()=='0'"
instead of using
root.child('userRegistration/' + auth.uid).child('profileTypeInfo').val()=='0'"
In other words, I need using the child data from the database 1 despite of using the root child, which not contains the child userRegistration
I do appreciate your help!
android firebase firebase-realtime-database
I'm developing an Android app using Firebase Realtime Database.
My project contains 3 distinct databases:
- Database 1: for common items;
- Database 2: for feature A;
- Database 3: for feature B;
In database 1, I'm able to create rules (working for this database) using its nodes to validate if specific user is able to read and write any data, for instance:
{
"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",
}
}
}
For this Database is OK, because I'm using the root.child of the current database. The issue is related to database A and B, because I'd like to use something like this:
database1.child('userRegistration/' + auth.uid).child('profileTypeInfo').val()=='0'"
instead of using
root.child('userRegistration/' + auth.uid).child('profileTypeInfo').val()=='0'"
In other words, I need using the child data from the database 1 despite of using the root child, which not contains the child userRegistration
I do appreciate your help!
android firebase firebase-realtime-database
android firebase firebase-realtime-database
edited Nov 12 at 11:55
KENdi
5,6592821
5,6592821
asked Nov 11 at 4:19
Gláucio Leonardo Sant'ana
1737
1737
why did you cut your database in 3 ? I'm not seeing any way to have global rules in firebase right now
– mcfly
Nov 11 at 14:48
1
Hi @mcfly, in my scope I do need separate in multiple data base due to different versions. If I use just one (as previously) I would do lof of stuff through java. I know how to do it via java but via Firebase rules are more reliable, I mean, I would spent to much effort do to the same in java
– Gláucio Leonardo Sant'ana
Nov 11 at 15:11
1
what about put your old version data into a sub collection and keep having only one databse ?
– mcfly
Nov 11 at 15:18
You're right! That would be a great possibility such as: Root (being able to use the rules easily) Subcollection 1 SubCollection 2 SubCollection 3
– Gláucio Leonardo Sant'ana
Nov 11 at 15:20
Glad it helps :)
– mcfly
Nov 11 at 15:38
add a comment |
why did you cut your database in 3 ? I'm not seeing any way to have global rules in firebase right now
– mcfly
Nov 11 at 14:48
1
Hi @mcfly, in my scope I do need separate in multiple data base due to different versions. If I use just one (as previously) I would do lof of stuff through java. I know how to do it via java but via Firebase rules are more reliable, I mean, I would spent to much effort do to the same in java
– Gláucio Leonardo Sant'ana
Nov 11 at 15:11
1
what about put your old version data into a sub collection and keep having only one databse ?
– mcfly
Nov 11 at 15:18
You're right! That would be a great possibility such as: Root (being able to use the rules easily) Subcollection 1 SubCollection 2 SubCollection 3
– Gláucio Leonardo Sant'ana
Nov 11 at 15:20
Glad it helps :)
– mcfly
Nov 11 at 15:38
why did you cut your database in 3 ? I'm not seeing any way to have global rules in firebase right now
– mcfly
Nov 11 at 14:48
why did you cut your database in 3 ? I'm not seeing any way to have global rules in firebase right now
– mcfly
Nov 11 at 14:48
1
1
Hi @mcfly, in my scope I do need separate in multiple data base due to different versions. If I use just one (as previously) I would do lof of stuff through java. I know how to do it via java but via Firebase rules are more reliable, I mean, I would spent to much effort do to the same in java
– Gláucio Leonardo Sant'ana
Nov 11 at 15:11
Hi @mcfly, in my scope I do need separate in multiple data base due to different versions. If I use just one (as previously) I would do lof of stuff through java. I know how to do it via java but via Firebase rules are more reliable, I mean, I would spent to much effort do to the same in java
– Gláucio Leonardo Sant'ana
Nov 11 at 15:11
1
1
what about put your old version data into a sub collection and keep having only one databse ?
– mcfly
Nov 11 at 15:18
what about put your old version data into a sub collection and keep having only one databse ?
– mcfly
Nov 11 at 15:18
You're right! That would be a great possibility such as: Root (being able to use the rules easily) Subcollection 1 SubCollection 2 SubCollection 3
– Gláucio Leonardo Sant'ana
Nov 11 at 15:20
You're right! That would be a great possibility such as: Root (being able to use the rules easily) Subcollection 1 SubCollection 2 SubCollection 3
– Gláucio Leonardo Sant'ana
Nov 11 at 15:20
Glad it helps :)
– mcfly
Nov 11 at 15:38
Glad it helps :)
– mcfly
Nov 11 at 15:38
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245800%2ffirebase-rules-for-multiple-databses%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
why did you cut your database in 3 ? I'm not seeing any way to have global rules in firebase right now
– mcfly
Nov 11 at 14:48
1
Hi @mcfly, in my scope I do need separate in multiple data base due to different versions. If I use just one (as previously) I would do lof of stuff through java. I know how to do it via java but via Firebase rules are more reliable, I mean, I would spent to much effort do to the same in java
– Gláucio Leonardo Sant'ana
Nov 11 at 15:11
1
what about put your old version data into a sub collection and keep having only one databse ?
– mcfly
Nov 11 at 15:18
You're right! That would be a great possibility such as: Root (being able to use the rules easily) Subcollection 1 SubCollection 2 SubCollection 3
– Gláucio Leonardo Sant'ana
Nov 11 at 15:20
Glad it helps :)
– mcfly
Nov 11 at 15:38