Reputation: 4066
I am trying to set the value of the "seen" key to true for all children.
Is there a simple way to do this?
Fetching all children to update each one individually seems like would be way overkill.
Thanks in advance for any help.
Upvotes: 0
Views: 415
Reputation: 1647
Gather all the keys from all_notifications and create a dictionary where you you update all the seen keys to true.
Just do it with one call like so:
ref.updateChildValues([key1: true, key2: true])
But it would make more sense to have another child under all_notifications where you store all the notification keys that are unseen.
Upvotes: 1
Reputation: 317362
There is no simple way to do this. At the very least, you're going to have to get a hold of all the keys for all the children in order to be able to write into them. With what you're showing now, the only way to do that is to fetch all the children so that you can construct references to them that can update each of their seen
keys.
Upvotes: 0