I have an element I want removed from Firebase that exists in multiple paths.
What is considered good practice to accomplish this in one transaction?
I searched and only thing I could find was, for example, this :
let dictionary = [ path1 : nil,
path2 : nil ]
DatabaseReference.updateChilds(dictionary)
Also, using NSNull() instead of nill didn't work either
But this throws an exception since I cannot use an update method to remove children.
Help would be appreciated.
Edit:
The exception I'm getting:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of items in section 0. The number of items contained in an existing section after the update (1) must be equal to the number of items contained in that section before the update (1), plus or minus the number of items inserted or deleted from that section (0 inserted, 1 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out).
The object is deleted once a button is clicked, and it activates a segue that is connected to this function:
@IBAction func unwindFromDeleteSegue(segue: UIStoryboardSegue)
{
if (prodToLoad != nil)
{
for cell in ProductsCollection.visibleCells as! [ProductsCollectionViewCell]
{
if ( cell.productUniqueID == prodToLoad?.UniqueID())
{
let indexPath = self.ProductsCollection.indexPath(for: cell)
_ = self.ProductsCollection.numberOfItems(inSection: 0)
ProductsCollection.deleteItems(at: [indexPath!])
}
}
}
ProductsCollection.reloadData()
}
Edit:
Items is now properly deleted from collection, but still isn't deleted from Firebase...