FirestoreGoogleAppsScript
FirestoreGoogleAppsScript copied to clipboard
Unable to update nested fields with custome mask in updateDocument()
The custom mask is interpreted as a whole field name instead of the nested field name. Therefore there is no way to update a nested field with it.
Minimal code to reproduce the problem
const firestore = FirestoreApp.getFirestore(email, key, projected);
const original = {
field1: 'value1',
field2: 'value2',
field3: {
field4: 'value4',
field5: 'value5',
},
'field3.field4': 'value3.4',
}
const update = {
field3: {
field4: 'new value4',
},
'field3.field4': 'new value3.4',
}
firestore.createDocument('TestCol/TestDoc', original);
var updated = firestore.updateDocument('TestCol/TestDoc', update, ['field3.field4']);
Expected Behavior
updated = {
field1: 'value1',
field2: 'value2',
field3: {
field4: 'new value4', //<-- Updated
field5: 'value5',
}
'field3.field4': 'value3.4',
}
Actual Results
updated = {
field1: 'value1',
field2: 'value2',
field3: {
field4: 'value4',
field5: 'value5',
}
'field3.field4': 'new value3.4', //<-- Updated
}