2017년 6월 30일 금요일

Can Firebase DB ProjectBucket be an empty string


I just want to check that I've done this correct.

For FirebaseURL I have entered my URL as per the URL give in firebase (databaseURL). Now if I choose a child node as my ProjectBucket everything works fine. However I want to look at my root folder, so when I set the ProjectBucket as an empty string, I then have problems with reading values from my tags. Now trying to work out best approach.

My example is as follows:

FirebaseURL= https://myprojectname.firebaseio.com

Root structure

myprojectname
 - child1
   -- tagName1
   -- tagName2
   -- etc.
 - child2
   -- tagName1
   -- tagName3
   -- tagName4
   -- etc.
 - child3
   -- tagName1
   -- tagName5
   -- etc.

As you can see within my structure I have used the same tagName (i.e. tagName1) in each of my child nodes. 

So in this case, if I then set my ProjectBucket as "child1" and apply the "GetValue" function with tag set as "tagName1", then change the ProjectBucket to "child2" and apply "GetValue" with tag set as "tagName1" I have problems with the async call "when FirebaseDB.gotValue" as the tag names are the same.

This is why I tried to get around this by setting ProjectBucket as "" and then setting my tags as "child1/tagName1" and "child2/tagName2", but for some reason I don't get values back.

Am I doing something wrong.

--
Apologies. I've found that my error is unrelated to the firebase component.

I've now done some more tests and ProjectBucket as empty string does work. I also tested having my tag as empty string with ProjectBucket pointing to the same tag name. This worked too.

What I did notice is that for complex nested structures your returned value can be in a json formatted string. Hence this is what caused me my problems.

--
Just to expand on your follow up: If you only send data from App Inventor to Firebase, we will encode it in such a way that it should always be interpreted correctly by App Inventor apps. However, if you provide the data through the Firebase web interface or another app using Firebase, then you can end up with JSON-encoded content that App Inventor doesn't understand. I hope that helps explain the difference in behavior you are experiencing.

--
Thanks for the explanation. Yes it pays to test as sometimes the returned values are seen as a list and other times as json formatted text.

Also tag names are case sensitive so be sure to check... this also caught me out.

--

댓글 없음:

댓글 쓰기