Open ronlinet opened 3 years ago
Simply recreating all collection with updated attribute does the trick. Working code :
$this->firestoreServiceAccount = ServiceAccount::fromJsonFile( storage_path() . '/app/google-services.json');
$this->firestore = (new Factory)->withServiceAccount($this->firestoreServiceAccount)->createFirestore();
$collection = $this->firestore->collection('users')->document( (int) $user->id );
$email = $collection->snapshot()->data()['email'];
$fcm_registration_token = $collection->snapshot()->data()['fcm_registration_token'];
$collection->set
(
[
'fcm_registration_token' => $fcm_registration_token,
'email' => $email,
'alert_notifications' => $user->alert_notifications,
]
);
@morrislaptop should we check the Update feature checkbox in the library TODO list and include the above code in the demo code ?
The bellow code is updating the 'alert_notification' User attribute but deleting all other fields. What is the correct approach to update a collection element without destroying all other fields?