Reputation: 13033
This is my database:
How can I delete key "2" in lotteryIDs under the map private? I tried this:
db.collection("users").document(currentUser.uid).updateData([
"private": ["lotteryIDs" : ["2" : FieldValue.delete()]]
])
And now I got the error as described in the title. Using:
"private/lotteryIDs/\(id)": FieldValue.delete
obviously did not work out well. I could not find it in the docs where they only explain how to delete top-level fields, not fields within objects.
Upvotes: 6
Views: 3713
Reputation: 16309
You should be able to use a dotted field path with updateData:
db.collection("users").document(currentUser.uid).updateData([
"private.lotteryIDs.2" : FieldValue.delete()])
Upvotes: 16