File tree Expand file tree Collapse file tree 2 files changed +3
-15
lines changed
Expand file tree Collapse file tree 2 files changed +3
-15
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ module.exports.replicateMasterToDetail = integrify({
3636 collection: ' detail1' ,
3737 foreignKey: ' masterId' ,
3838 attributeMapping: {
39- masterField1: ' detail1Field1' ,
39+ masterField1: ' detail1Field1' , // If an field is missing after the update, the field will be deleted
4040 masterField2: ' detail1Field2' ,
4141 },
4242 },
Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ export interface ReplicateAttributesRule extends Rule {
1313 [ sourceAttribute : string ] : string ;
1414 } ;
1515 isCollectionGroup ?: boolean ;
16- deleteMissing ?: boolean ;
1716 } [ ] ;
1817 hooks ?: {
1918 pre ?: Function ;
@@ -99,23 +98,12 @@ export function integrifyReplicateAttributes(
9998 rule . targets . forEach ( target => {
10099 const targetCollection = target . collection ;
101100 const update = { } ;
102- let shouldDelete = false ;
103-
104- if ( target . deleteMissing ) {
105- shouldDelete = target . deleteMissing ;
106- }
107101
108102 // Create "update" mapping each changed attribute from source => target,
109103 // if delete is set delete field
110104 Object . keys ( target . attributeMapping ) . forEach ( changedAttribute => {
111- if ( newValue [ changedAttribute ] ) {
112- update [ target . attributeMapping [ changedAttribute ] ] =
113- newValue [ changedAttribute ] ;
114- } else if ( shouldDelete ) {
115- update [
116- target . attributeMapping [ changedAttribute ]
117- ] = FieldValue . delete ( ) ;
118- }
105+ update [ target . attributeMapping [ changedAttribute ] ] =
106+ newValue [ changedAttribute ] || FieldValue . delete ( ) ;
119107 } ) ;
120108
121109 console . log (
You can’t perform that action at this time.
0 commit comments