Skip to content

Unable to update nested fields with custome mask in updateDocument() #146

@zhezhang77

Description

@zhezhang77

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
}
Library Version: Head

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions