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>(
10
10
) : Promise < void > {
11
11
const preparedResourceName = snakeToCamel ( this . repository . metadata . name ) ;
12
12
const { id } = options . route ;
13
-
13
+ const primaryID = this . repository . metadata . primaryColumns [ 0 ] . propertyName ;
14
14
const builder = this . repository . createQueryBuilder ( preparedResourceName ) ;
15
- builder . where ( { id } ) ;
15
+ builder . where ( { [ primaryID ] : id } ) ;
16
16
17
17
const result = await builder . getOne ( ) ;
18
18
if ( ! result ) {
Original file line number Diff line number Diff line change @@ -55,10 +55,11 @@ export async function getOne<T>(
55
55
} ) ;
56
56
} ) ;
57
57
}
58
+ const primaryID = this . repository . metadata . primaryColumns [ 0 ] . propertyName ;
58
59
const prepareParams = Date . now ( ) - startTime ;
59
60
const result = await builder
60
61
. select ( [ ...fieldsSelect ] )
61
- . where ( { id } )
62
+ . where ( { [ primaryID ] : id } )
62
63
. getRawMany ( ) ;
63
64
64
65
if ( result . length === 0 ) {
Original file line number Diff line number Diff line change @@ -29,9 +29,9 @@ export async function patchOne<T>(
29
29
detail : "Data 'id' must be equal to url param" ,
30
30
} ) ;
31
31
}
32
-
32
+ const primaryID = this . repository . metadata . primaryColumns [ 0 ] . propertyName ;
33
33
const whereCondition = {
34
- id : Equal ( id ) ,
34
+ [ primaryID ] : Equal ( id ) ,
35
35
} as unknown as FindOptionsWhere < T > ;
36
36
37
37
const target = await this . repository . findOne ( {
You can’t perform that action at this time.
0 commit comments