UpdateDocumentAsync api has required parameters document and updateMask
The document just state that if any fields does not specified in the mask it would not be overridden. Which means if document already exist and we put an empty new DocumentMask() it would not write any changed field existing isn't it?
If it behave like this, what API should we call for override everything?
If you specify an empty document mask, it wouldn't change any fields - or would throw an exception; I can't remember offhand.
If you want to completely overwrite the existing data, use Set instead of Update.
@jskeet I see. Because I have seen no Set api for the low level firestoreClient
So I just look for high level and it seem Set just use ExtractDocumentMask then update
Is it really normal for firestore that we use update with mask of all field to override everything?
I believe so, but I'd have to look at the code in more detail to check. (I'm currently at a conference, just trying to catch up with mail - I'm not working in my normal capacity this week.) Again, for low-level API details it's probably best to ask in a Firestore-specific forum rather than here, as I'm really not an expert in Firestore in general.
cc @schmidt-sebastian
The Firestore clients use create, set and update for the same Protobuf operation. They each use the Protobuf in a slightly different way. set by default overrides the data on the server, and this is achieved by not sending a document mask to the backend.
@schmidt-sebastian Thank you very much. Is that was documented anywhere? Because I have seen only mention that a field which not exist in mask will not get update, but it I have seen nowhere mention that if there is no mask at all it would be full overridden
I suspect this behavior just not sure and not see document about it
@schmidt-sebastian And also I have seen Firestore api was implemented by using ExtractDocumentMask which means it send every field as a mask instead of just no mask?
The code path you've shown is when SetOptions.Merge is set to true.
Otherwise, it uses an empty set of paths:
I suspect this behavior just not sure and not see document about it
As far as I can tell, this is not yet documented in the Protobuf definition. I created an internal PR to add this caveat.
Thank you very much for all of responses