I am trying to delete data from several locations in the Firebase database simultaneously.
The Firebase docs state:
"The simplest way to delete data is to call removeValue on a reference to the location of that data. You can also delete by specifying nil as the value for another write operation such as setValue or updateChildValues. You can use this technique with updateChildValues to delete multiple children in a single API call."
My code is
let childUpdates = [path1 : nil,
path2 : nil,
path3 : nil,
path4 : nil]
ref.updateChildValues(childUpdates)
All four paths are strings, but I get an error:
"Type of expression is ambiguous without more context."
I'd assume this occurs because of the nil values, since if I replace nil with anything else (such as an Int) the error disappears.
What is the correct way to use updateChildValues to delete data from Firebase? We want it to work in a similar way to the removeValue() function in Firebase. The reason we would prefer to do this is because it can remove from multiple places in one call.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…