0

I'm making an iOS SNS app using firebase. In my app, you can change your username in the setting. But even after you change your username, username in posts that you before posted is still your old username because each post includes your username when you posted it.

Is there any solution to update every post's user name when you change your username?

Thanks in advance!

Yutaro
  • 89
  • 1
  • 10

1 Answers1

0

As far as I know you can't trigger onWrite() on authentication properties. Maybe you can store the username in your database and use it as the author of each post. Then you can use cloud functions to listen to 'user' node changes and update all posts whose author is equal to the previous username (better user an ID to handle this update).

Hope it helps. Maybe someone else have a better idea.

soutot
  • 3,531
  • 1
  • 18
  • 22