File tree 1 file changed +7
-7
lines changed
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 {
19
19
20
20
updateGlobalConfig ( req ) {
21
21
const params = req . body . params ;
22
- const update = { } ;
23
- Object . keys ( params ) . forEach ( ( key ) => {
22
+ const update = Object . keys ( params ) . reduce ( ( acc , key ) => {
24
23
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 } ` ] = "" ;
27
26
} 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 ] ;
30
29
}
31
- } ) ;
30
+ return acc ;
31
+ } , { } ) ;
32
32
return req . config . database . adaptiveCollection ( '_GlobalConfig' )
33
33
. then ( coll => coll . upsertOne ( { _id : 1 } , update ) )
34
34
. then ( ( ) => ( { response : { result : true } } ) ) ;
You can’t perform that action at this time.
0 commit comments