Code to get just the keys (nodes, childnames, ...) of a Database path.
It makes use of the "shallow" parameter, which is crucial if you work with large datasets.
The "Starter.strFirebaseProjectRefUrl" is the URL you see on top of the database console:
It makes use of the "shallow" parameter, which is crucial if you work with large datasets.
B4X:
wait for (FireBaseRTDB_EnumerateChilds("groups/cats")) complete(mapNodes As Map)
Dim jg As JSONGenerator
jg.Initialize(mapNodes)
Log(jg.ToPrettyString(2))
B4X:
Sub FireBaseRTDB_EnumerateChilds(strNode As String) As ResumableSub
' Info --> https://firebase.google.com/docs/database/rest/retrieve-data#shallow
Dim mapRet As Map
mapRet.Initialize
Dim j As HttpJob
j.Initialize("", Me)
j.Download(Starter.strFirebaseProjectRefUrl & strNode & ".json" & "?shallow=true")
wait for (j) JobDone(job As HttpJob)
If job.Success Then
Dim JSON As JSONParser
JSON.Initialize(j.GetString)
mapRet = JSON.NextObject
For Each k As String In mapRet.Keys
mapRet.Put(k, Starter.strFirebaseProjectRefUrl & strNode & ".json")
Next
End If
job.Release
Return mapRet
End Sub
The "Starter.strFirebaseProjectRefUrl" is the URL you see on top of the database console: