Skip to content

Commit b17dfc6

Browse files
author
Alexander Kharkovey
committed
fix(json-api-nestjs): correct name for id field
1 parent 823b868 commit b17dfc6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

libs/json-api-nestjs/src/lib/mixin/service/transform/transform.mixin.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,12 @@ export class TransformMixinService<T> {
235235
},
236236
};
237237
}
238-
238+
const idNameField =
239+
table === this.currentResourceName
240+
? this.currentPrimaryField
241+
: this.relationPrimaryField.get(table);
239242
return {
240-
id: data[this.currentPrimaryField].toString(),
243+
id: data[idNameField].toString(),
241244
type: urlTable,
242245
attributes,
243246
relationships,

0 commit comments

Comments
 (0)