Skip to content

Conversation

@michaelprichardson
Copy link
Collaborator

From issue #8, the new feature deletes a field in the target collection docs, the deleteMissing flag defaults to false. Field needs to be in the attribute mapping to be removed for example:

collection: 'detail1',
foreignKey: 'tempId',
attributeMapping: {
    masterDetail1: 'foreignDetail1',
    masterDetail2: 'foreignDetail2',
},
deleteMissing: true,

if the after snapshot is (master):

{ masterDetail1: 'some_new_detail' }

The foreignDetail2 will be deleted from the target snapshot as masterDetail2 is not there and maps to foreignDetail2

@michaelprichardson michaelprichardson linked an issue Jul 22, 2020 that may be closed by this pull request
@michaelprichardson
Copy link
Collaborator Author

Added the same feature that was added to the deleteReference, the source primary key can be specified otherwise it will be set to the default masterId:

source: {
    collection: 'master', // <-- This will append {masterId}
    // OR
    collection: 'master/{masterId}', // <-- Can be any string as in Firebase
},

@nbransby
Copy link
Member

Do we need the deleteMissing flag? I understand that it preserves the existing behavior but Im not sure that's good thing - I cant think of a use case where you would want the last stale value left in the target when the field gets deleted in the source let alone making this the default behavior.

I believe this warrants a breaking change - and and major version number increase

@nbransby
Copy link
Member

Want to update the version no. is this PR?

@michaelprichardson
Copy link
Collaborator Author

Yeah sure. I was going to do it in #4

@nbransby nbransby merged commit fe29649 into master Jul 23, 2020
@nbransby nbransby deleted the delete-field-from-target-when-not-in-source branch July 23, 2020 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delete field from target when not in source

3 participants