Skip to content

Commit 2977214

Browse files
author
Mateus Garcia
committed
fix(json-api-nestjs): transform entity name back to camel
1 parent 8d7aaa5 commit 2977214

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

libs/json-api-nestjs/src/lib/helper/utils/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,10 @@ export function getProviderName(entity: EntityTarget<Entity>, name: string) {
5454
const entityName = getEntityName(entity);
5555
return `${upperFirstLetter(entityName)}${name}`;
5656
}
57+
58+
export function kebabToCamel(str: string) {
59+
return str
60+
.split('-')
61+
.map((i) => i.charAt(0).toUpperCase() + i.substring(1))
62+
.join('');
63+
}

libs/json-api-nestjs/src/lib/mixin/service/typeorm/utils/utils-methode.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ import {
1818
ServiceOptions,
1919
ValidationError,
2020
} from '../../../../types';
21-
import { snakeToCamel, getEntityName, camelToKebab } from '../../../../helper';
21+
import {
22+
snakeToCamel,
23+
getEntityName,
24+
camelToKebab,
25+
kebabToCamel,
26+
} from '../../../../helper';
2227
import {
2328
OperandMapForNull,
2429
OperandMapForNullRelation,
@@ -355,7 +360,7 @@ export class UtilsMethode {
355360
const relationsTypeName = isArray ? data[0]['type'] : data['type'];
356361

357362
const result = await repository.manager
358-
.getRepository(relationsTypeName)
363+
.getRepository(kebabToCamel(relationsTypeName))
359364
.find({
360365
select: {
361366
id: true,

0 commit comments

Comments
 (0)