My data looks like this
"countries": [
0: [name: "USA", capital: "Washington"],
1: [name: "Canada", capital: "Ottawa"]
]
If I want to delete the countries
where the capital
is "Ottawa"
, how do I do it?
I tried
currentDocument.updateData([
"countries": FieldValue.arrayRemove("Ottawa")
]) { err in
if let err = err {
print("Error updating document: \(err)")
} else {
print("Document successfully updated")
}
}
But this just deletes the entire array. Even if I try to target the specific country ("countries.1.name": FieldValue.arrayRemove("Ottawa")
) it doesn't work and just deletes the entire array again.
What am I doing wrong?