I have the following function
Future<void> _updateDocument(String path, {Map<String, dynamic> data}) async {
final Map<String, dynamic> stampedData = {'updatedAt': FieldValue.serverTimestamp()};
if (data != null) stampedData.addAll(data);
try {
print('Updating document : $path with $stampedData');
final DocumentReference documentReference = _fireStore.document(path);
await documentReference.updateData(stampedData);
} on PlatformException catch (error) {
throw UserFriendlyException('Operation Failed', error.message);
}
}
Which updates a certain document. But I keep getting the following error
Write failed at groups/YUUjiGgQ6De4IMshWmRF: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null}
Because I have the following rule
incomingData().keys().hasOnly(['updatedAt', 'displayName']) == true
So I tested how many keys there actually are and it turns out there are 5 keys
function isValidGroupRename(){
return incomingData().keys().hasAll(['updatedAt', 'displayName']) == true &&
incomingData().keys().size() < 6
}
Because this functions passes the test but < 5
does not. When I look at the data object right before the I call the update, so this line print('Updating document : $path with $stampedData');
it tells me that I only update 2 values
Updating document : groups/YUUjiGgQ6De4IMshWmRF with {updatedAt: FieldValue(Instance of 'MethodChannelFieldValue'), displayName: jjjjjgi}
So does FieldValue.serverTimestamp() add on fields? And if so what are those fields so I can check for them.