capítulo 3.2: Uso de bases de datos en tiempo real de Firebase

PHOTO EMBED

Wed Mar 01 2023 10:38:29 GMT+0000 (Coordinated Universal Time)

Saved by @swiftui_spanish #firebase #swiftui #firestore #firestorage #firebaseauth

// Escribir datos
ref.child("users").child("userId").setValue(["name": "John", "age": 30])

// Leer datos
ref.child("users").child("userId").observeSingleEvent(of: .value) { (snapshot) in
  if let value = snapshot.value as? [String: Any] {
    let name = value["name"] as? String ?? ""
    let age = value["age"] as? Int ?? 0
    print("Name: \(name), Age: \(age)")
  }
}
content_copyCOPY