File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -19,16 +19,16 @@ export class GlobalConfigRouter extends PromiseRouter {
1919
2020 updateGlobalConfig ( req ) {
2121 const params = req . body . params ;
22- const update = { } ;
23- Object . keys ( params ) . forEach ( ( key ) => {
22+ const update = Object . keys ( params ) . reduce ( ( acc , key ) => {
2423 if ( params [ key ] && params [ key ] . __op && params [ key ] . __op === "Delete" ) {
25- if ( ! update . $unset ) update . $unset = { } ;
26- update . $unset [ " params." + key ] = "" ;
24+ if ( ! acc . $unset ) acc . $unset = { } ;
25+ acc . $unset [ ` params.${ key } ` ] = "" ;
2726 } else {
28- if ( ! update . $set ) update . $set = { } ;
29- update . $set [ " params." + key ] = params [ key ] ;
27+ if ( ! acc . $set ) acc . $set = { } ;
28+ acc . $set [ ` params.${ key } ` ] = params [ key ] ;
3029 }
31- } ) ;
30+ return acc ;
31+ } , { } ) ;
3232 return req . config . database . adaptiveCollection ( '_GlobalConfig' )
3333 . then ( coll => coll . upsertOne ( { _id : 1 } , update ) )
3434 . then ( ( ) => ( { response : { result : true } } ) ) ;
You can’t perform that action at this time.
0 commit comments