Home > OS >  How to remove multiple children in one call - Realtime Firebase
How to remove multiple children in one call - Realtime Firebase

Time:01-25

I wan to delete multiple children with known key. I searched all the related posts but it doesn't seem to work. It shows red bracket.

Below is my code which i refer from other posts:

var updates = { } 

for(i in removedProductVariationIdList){
    updates["user/$i"] = null
}

Screenshot:

enter image description here

Firebase Structure (I want to remove 3, 4 under Product_Variation for example, which i know the key) :

enter image description here

CodePudding user response:

Java doesn't support template literals with the $i notation in regular strings, as far as I know. The simplest way to build a map with the null values:

Map<String, Object> updates = new HashMap<>();
for(i in removedProductVariationIdList){
    updates.put("user" i, null);
}

Also see:

  • enter image description here

  •  Tags:  
  • Related