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:
Firebase Structure (I want to remove 3, 4 under Product_Variation for example, which i know the key) :
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:
You need to declare values
as a map.
val map = mutableMapOf<String, Any?>()
Solution:
With the help from Frank's reference link and danartillaga answers, below is my code in Kotlin
which works:
val productVariationRef = FirebaseDatabase.getInstance().getReference("Product_Variation")
val updates = hashMapOf<String, Any?>()
for (i in removedProductVariationIdList){
updates.put("/$i", null)
}
productVariationRef.updateChildren(updates)
Firebase Structure - It will delete all the key (e.g. 3, 4, 5, 8) stored in removedProductVariationIdList
together with its children, whole branch dissapears, which is exactly what i want :
Firebase Cloud Functions: PubSub, "res.on is not a function"
TypeError: Cannot read properties of undefined (reading 'createMessageComponentCollector')
Preface: using Nodejs w/Express to build a blog website and using multer to upload an image to mongoDB
Hello may I ask if it is possible to make a MYSQL table to read only? In which I had a table for student records which is to be updated whenever a user/student registers which saves details from the MYSQL database which is non-modifiable due to being read onlyIf...
I run php artisan route:cache ,I didn't notice that this command can only run in production and cause this error when I want to run php artisan route:list