I'm using Firebase RealTime Database. For example, i have 100,000 users, all of which have different scores. What i want to do is to make all of users' scores zero at one time. How can i do that? By the way, the content of the "score" field is "integer."
Asked
Active
Viewed 37 times
0
-
You're asking about a multi-location update, and I address that in my answer to [this question](https://stackoverflow.com/questions/38462074/using-updatechildvalues-to-delete-from-firebase/38466959#38466959). However, if there's a need to write the same value to 100,000 child nodes, there may be more of a Firebase structure issue than anything and you may need to alter the structure to better handle that. Without understanding the use case or structure, it's impossible to answer accurately. – Jay Jul 03 '20 at 20:17
1 Answers
1
I doubt that is possible. A better way is to create a separate tag for scores.
Users
- User1
- data
- User2
- data
- User3
- data
Scores
- User1: 56
- User2: 30
- User3: 23
This way you can simply delete the Score
tag and reset all users.
Another way would be traversing through the whole database and resetting the value with firebase cloud functions.
Another way would be using App Engine backend which has a simple servlet and a cron task

fatalcoder524
- 1,428
- 1
- 7
- 16
-
You can definitely write to multiple locations at one time. 100,000 is probably not practical but it can certainly be done. See my comment to the question. Oh - and this is a very good answer with great suggestions - just wish the question was a bit more clear. – Jay Jul 03 '20 at 20:18
-
Users have user_id,user_name,email and score.. And for example I have 100.000 users.. ahmet - 5200 points mehmet - 6500 points ali - 7200 points ........................ ....................... ....................... I want to do all users score "0(zero)".. How Can I Do?? – Egemen AY Jul 03 '20 at 21:38
-
@EgemenAY That comment is your question re-posted as a comment. If you have more information to add, please update your question with that information. – Jay Jul 03 '20 at 22:02