Alk
Alk

Reputation: 5567

Remove Child From Firebase removes whole node swift

I have the following data structure:

"feed" : {
 "756135 Washington" : {
  "VbMvwmlNqGNUY44JmfPp" : {
    "downvotes" : "downvotes",
    "timestamp" : 1483396793247,
    "upvotes" : {
      "i5KHwJzhTTfA6FJ8Fb2qLHuLjHi2" : {
        "timestamp" : 1483396826253
      }
    },
  }
 }
}

Now I want to remove the i5KHwJzhTTfA6FJ8Fb2qLHuLjHi2 node under upvotes but I still want the upvotes node to stay, just without any children. I'm using the following code, however this removes the whole node.

 ref?.child("feed").child(city_localizer_string!).child(id!).child("upvotes").child(uid).removeValue()

Upvotes: 1

Views: 471

Answers (1)

timothyjosefik
timothyjosefik

Reputation: 126

Anything empty in firebase will always be removed automatically. Even if you try and create a new child with the value of nil it won't be added to your database.

Upvotes: 1

Related Questions