0

I am using Firebase SDKs in iOS app, I want to show db all nodes which I created in firebase db in application, is there any way to show database all nodes list to application user without hardcoding?

I tried below solution to print all data from main node, but couldn't

let ref:DatabaseReference = Database.database().reference()

ref.observe(.value) { snapshot in
     print("DATA FETCH1: \(snapshot)")
}

let hand:DatabaseHandle
let refq:DatabaseReference = Database.database().reference()
hand = refq.observe(DataEventType.value, with: { (snapshot) in
     let postDict = snapshot.value as? [String : AnyObject] ?? [:]
     print("DATA FETCH2: \(postDict)")
})
Scorpian Alive
  • 734
  • 8
  • 21
  • The Firebase Database doesn't have the concept of tables. It's probably easiest to understand what you're trying to accomplish if you edit your question to include a snippet of the JSON (as text, no screenshots). You can get this by clicking the "Export JSON" link in your [Firebase Database console](https://console.firebase.google.com/project/_/database/data). It also would be good if you could show what you've already tried, since the Firebase docs should provide you some great starter material. – Frank van Puffelen Jul 16 '18 at 18:19
  • Hi @FrankvanPuffelen Thanks for reply, – Scorpian Alive Jul 16 '18 at 18:38
  • I want to print all data in my application from main node, is it possible? I tried many code snippets but it not worked. Thanks – Scorpian Alive Jul 16 '18 at 18:39
  • 1
    That's definitely possible. See this question for an example: https://stackoverflow.com/questions/50207287/how-to-read-the-parent-node-name-without-getting-value-from-firebase-for-iosBut loading all top-level nodes, means that you'll be downloading your entire database. Depending on how much data you have, that may be unacceptable. See https://stackoverflow.com/questions/37365866/firebase-2016-shallow-query – Frank van Puffelen Jul 16 '18 at 19:48
  • Thanks @FrankvanPuffelen , you saved lots of my time, it really worked, I appreciate your help – Scorpian Alive Jul 17 '18 at 12:25

0 Answers0