File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed
packages/server/src/api/rest Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -848,6 +848,7 @@ class RequestHandler extends APIHandlerBase {
848848 return error ;
849849 }
850850
851+ const matchFields = ( requestBody as any ) . meta . matchFields ;
851852 const uniqueFields = Object . values ( modelMeta . models [ type ] . uniqueConstraints || { } ) . map ( ( uf ) => uf . fields ) ;
852853
853854 if (
@@ -856,14 +857,12 @@ class RequestHandler extends APIHandlerBase {
856857 return this . makeError ( 'invalidPayload' , 'Match fields must be unique fields' , 400 ) ;
857858 }
858859
859- const matchFields = ( requestBody as any ) . meta . matchFields ;
860-
861- const upsertPayload : any = { } ;
862- upsertPayload . where = this . makeUpsertWhere ( matchFields , attributes , typeInfo ) ;
863-
864- upsertPayload . create = { ...attributes } ;
865- upsertPayload . update = {
866- ...Object . fromEntries ( Object . entries ( attributes ) . filter ( ( e ) => ! matchFields . includes ( e [ 0 ] ) ) ) ,
860+ const upsertPayload : any = {
861+ where : this . makeUpsertWhere ( matchFields , attributes , typeInfo ) ,
862+ create : { ...attributes } ,
863+ update : {
864+ ...Object . fromEntries ( Object . entries ( attributes ) . filter ( ( e ) => ! matchFields . includes ( e [ 0 ] ) ) ) ,
865+ } ,
867866 } ;
868867
869868 if ( relationships ) {
You can’t perform that action at this time.
0 commit comments