//Para actualizar datos en la base de datos, podemos utilizar el siguiente código:
let documentRef = db.collection("cities").document("SF")
documentRef.updateData([
"population": 884363,
"capital": false
]) { error in
if let error = error {
print("Error al actualizar datos: \(error.localizedDescription)")
return
}
print("Datos actualizados con éxito")
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter