Firebase is a NoSQL JSON database and has no schema and tables. Data is stored with a tree structure with nodes; parents and children.
You do not need to analyze Firebase JSON data to access it, you can access it directly.
FDataSnapshots contains the key .key, which is the parent key in Firebase and .value..Value can contain one node or several nodes. The value will have key: value pairs representing the data in the snapshot
, Firebase,
dogs
dog_id_0
title: "dog"
type: "Alaskan Malamute"
images:
main: "dog.png"
others:
0: "1.png"
1: "2.png"
dog_id_1
title: "another dog"
type: "Boxer"
images:
main: "another_dog.png"
others:
0: "3.png"
1: "4.png"
, , dog_id_x node .
var ref = Firebase(url:"https://your-app.firebaseio.com/dogs")
ref.observeEventType(.ChildAdded, withBlock: { snapshot in
println(snapshot.value.objectForKey("title"))
println(snapshot.value.objectForKey("type"))
})
dog
Alaskan Malamute
another dog
Boxer
Dog_id_0 dog_id_1 - node, FirebaseByAutoId.
Dog FDataSnapshot, .