Skip to content

Commit 69d84a9

Browse files
authored
Merge pull request #17 from klerick/fix-id-field-name
fix(json-api-nestjs): correct name for id field
2 parents 823b868 + b17dfc6 commit 69d84a9

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)