Consider a collection of users
. Each document in the collection has name
and email
as fields.
{
\"users\": {
\"uid1\
To solve this, you need to update each user to have the new property and for that I recommend you to use a Map
. If you are using a model class when you are creating the users as explained in my answer from this post, to update all users, just iterate over the users
collection amd use the following code:
Map map = new HashMap<>();
map.put("timestamp", FieldValue.serverTimestamp());
userDocumentReference.set(map, SetOptions.merge());