Jason Singh
Jason Singh

Reputation: 75

Is there any way to update multiple child values at once?

I need to set all the child distances to 0 (check photo of Firebase db below) in 1 setting. Is there any way I can do this? The usual update function for Firebase generally works for only one userID.

Photo of Firebase DB:

Upvotes: 0

Views: 745

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598718

To write a value, the client must specify the complete path to that value in the database. Firebase does not support the equivalent of SQL's update queries.

So you will need to first load the data, and then update each child. You can perform those updates in a big batch if you want, using multi-location updates. For more on those, see the blog post introducing them and the answer here: Firebase - atomic write of multiple values to multiple locations

Upvotes: 1

Related Questions