Suppose, I have several fields in the favorites document and it looks like below:
{
favorites:
{
"color": "Red",
"place": "ocean",
"time": "morning"
}
}
Now, I want to update a single field in this document. If I write the below code to update a single field, will the request.resource.data contain only this field or will it also contain the other fields in this document?
db.collection("users")
.document("favorites")
.update({
"color": "Red"
});
The request.resource
variable contains the document as it'll exist after the update, if that update is allowed.
So request.resource.data
contains your updated color
and the place
and time
values from the existing document.