'Firebase: how to add/omit a field to/from an object rather than replacing the whole object? [duplicate]
I have a Firestore function where
admin
.firestore()
.collection('users')
.doc(context.params.userId)
.set({field1: false});
The problem is, this replaces the given user object with {field1: false}. I want to be able to add {field1: false} to the object while preserving all other existing fields, and also to be able to remove the field1 field from the object if it already exists.
How should I approach this?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
