Firebase rules for multiple databses









up vote
2
down vote

favorite
1












I'm developing an Android app using Firebase Realtime Database.
My project contains 3 distinct databases:



  1. Database 1: for common items;

  2. Database 2: for feature A;

  3. 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!










share|improve this question























  • 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














up vote
2
down vote

favorite
1












I'm developing an Android app using Firebase Realtime Database.
My project contains 3 distinct databases:



  1. Database 1: for common items;

  2. Database 2: for feature A;

  3. 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!










share|improve this question























  • 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












up vote
2
down vote

favorite
1









up vote
2
down vote

favorite
1






1





I'm developing an Android app using Firebase Realtime Database.
My project contains 3 distinct databases:



  1. Database 1: for common items;

  2. Database 2: for feature A;

  3. 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!










share|improve this question















I'm developing an Android app using Firebase Realtime Database.
My project contains 3 distinct databases:



  1. Database 1: for common items;

  2. Database 2: for feature A;

  3. 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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 at 11:55









KENdi

5,6492821




5,6492821










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
















  • 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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














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





















































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







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

Museum of Modern and Contemporary Art of Trento and Rovereto