Skip to content

Commit 1f9865d

Browse files
authored
Merge pull request #24 from klerick/fix-again
Fix again
2 parents 05dc1d2 + da58c7c commit 1f9865d

File tree

6 files changed

+11
-20
lines changed

6 files changed

+11
-20
lines changed

libs/json-api-nestjs-sdk/src/lib/service/json-api-utils/json-api-utils.service.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,6 @@ import { ObjectLiteral } from 'typeorm';
2626
export class JsonApiUtilsService {
2727
protected jsonApiSdkConfig = inject<JsonApiSdkConfig>(JSON_API_SDK_CONFIG);
2828
protected listEntities = inject<ListEntities>(ALL_ENTITIES);
29-
// protected patchEntities = inject<ListEntities>(PATCH_ENTITIES, {
30-
// optional: true,
31-
// });
32-
33-
constructor() {
34-
console.log(this.listEntities);
35-
}
36-
3729
public getUrlForResource(resource: string): string {
3830
const url: string[] = [camelToKebab(resource).toLocaleLowerCase()];
3931
if (this.jsonApiSdkConfig.apiPrefix) {

libs/json-api-nestjs-sdk/src/lib/token/json-api-sdk.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@ export interface ListEntities {
1111

1212
export const JSON_API_SDK_CONFIG = new InjectionToken<JsonApiSdkConfig>(
1313
'Main config object for sdk'
14-
// {
15-
// // providedIn: JsonApiNestjsSdkModule,
16-
// factory: () => {
17-
// console.log(inject(API_SDK_CONFIG, { optional: true }));
18-
// return inject(API_SDK_CONFIG, { optional: true }) as any;
19-
// },
20-
// }
2114
);
2215

2316
export const API_SDK_CONFIG = new InjectionToken<JsonApiSdkConfig>(

libs/json-api-nestjs/src/lib/factory/ajv/utils/input-body-post-schema.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ export function inputBodyPostSchema(
7777
type: 'boolean',
7878
};
7979
break;
80+
case Object:
81+
dataType = {
82+
type: 'object',
83+
};
84+
break;
8085
default:
8186
dataType = {
8287
type: 'string',

libs/json-api-nestjs/src/lib/mixin/service/typeorm/methods/delete-one/delete-one.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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) {

libs/json-api-nestjs/src/lib/mixin/service/typeorm/methods/get-one/get-one.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff 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) {

libs/json-api-nestjs/src/lib/mixin/service/typeorm/methods/patch-one/patch-one.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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({

0 commit comments

Comments
 (0)