0

My firebase real time database structure looks like this:

"aHB1ASJ895Adsws2": { // User id
    "lat": "48.023288102" // Users lat
    "lng": "-122.3324202" // and lng values

Before adding another of these to the parent node I would like to delete all nodes that have the current users id.

For example, if the current user id is 123 and there are 2 nodes which have a user id value of 123 then these nodes should be deleted before adding a new location for the current user into the firebase real time database.

How can I remove nodes with the same user id as the current user with the firebase real time database?

Tom Finet
  • 2,056
  • 6
  • 30
  • 54
  • [`ref.child(childID).removeValue()`](https://firebase.google.com/docs/reference/android/com/google/firebase/database/DatabaseReference.html#removeValue()) sets a node to null – mjr Aug 26 '16 at 16:15
  • 2
    Have you already had a look at the [documentation for Firebase Database queries](https://firebase.google.com/docs/database/android/retrieve-data#sorting_and_filtering_data) to see how you can select the nodes you want to delete? Also see [this answer](http://stackoverflow.com/questions/37390864/how-to-delete-from-firebase-realtime-database/37393676#37393676) that I gave a while ago. – Frank van Puffelen Aug 26 '16 at 16:16

0 Answers0