File tree Expand file tree Collapse file tree 3 files changed +6
-5
lines changed
libs/json-api-nestjs/src/lib/mixin/service/typeorm/methods Expand file tree Collapse file tree 3 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -10,9 +10,9 @@ export async function deleteOne<T>(
1010) : Promise < void > {
1111 const preparedResourceName = snakeToCamel ( this . repository . metadata . name ) ;
1212 const { id } = options . route ;
13-
13+ const primaryID = this . repository . metadata . primaryColumns [ 0 ] . propertyName ;
1414 const builder = this . repository . createQueryBuilder ( preparedResourceName ) ;
15- builder . where ( { id } ) ;
15+ builder . where ( { [ primaryID ] : id } ) ;
1616
1717 const result = await builder . getOne ( ) ;
1818 if ( ! result ) {
Original file line number Diff line number Diff line change @@ -55,10 +55,11 @@ export async function getOne<T>(
5555 } ) ;
5656 } ) ;
5757 }
58+ const primaryID = this . repository . metadata . primaryColumns [ 0 ] . propertyName ;
5859 const prepareParams = Date . now ( ) - startTime ;
5960 const result = await builder
6061 . select ( [ ...fieldsSelect ] )
61- . where ( { id } )
62+ . where ( { [ primaryID ] : id } )
6263 . getRawMany ( ) ;
6364
6465 if ( result . length === 0 ) {
Original file line number Diff line number Diff line change @@ -29,9 +29,9 @@ export async function patchOne<T>(
2929 detail : "Data 'id' must be equal to url param" ,
3030 } ) ;
3131 }
32-
32+ const primaryID = this . repository . metadata . primaryColumns [ 0 ] . propertyName ;
3333 const whereCondition = {
34- id : Equal ( id ) ,
34+ [ primaryID ] : Equal ( id ) ,
3535 } as unknown as FindOptionsWhere < T > ;
3636
3737 const target = await this . repository . findOne ( {
You can’t perform that action at this time.
0 commit comments