Skip to content

Commit 4282f9d

Browse files
author
Alexander Kharkovey
committed
fix(json-api-nestjs): skip relation with id null
1 parent fb0af92 commit 4282f9d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ export class TransformMixinService<T> {
141141
val
142142
);
143143
if (Array.isArray(acum[key])) {
144-
acum[key].push(plainObject);
144+
if (plainObject[this.relationPrimaryField.get(key)] !== null) {
145+
acum[key].push(plainObject);
146+
}
145147
} else {
146148
acum[key] = plainObject;
147149
}
@@ -181,7 +183,6 @@ export class TransformMixinService<T> {
181183
const propsData = data[field];
182184
const typeName = getEntityName(this.relationTarget.get(field));
183185
if (Array.isArray(propsData)) {
184-
console.log(propsData, this.relationPrimaryField.get(field));
185186
builtData.data = propsData.map((i) => ({
186187
type: camelToKebab(typeName),
187188
id: i[this.relationPrimaryField.get(field)].toString(),

0 commit comments

Comments
 (0)