Not able to add new entity, with reference to user with typeOrm #1705
Replies: 2 comments 3 replies
-
Update: In create-qna.dto.ts, I added but then error: src/qnas/qnas.service.ts:13:38 - error TS2345: Argument of type 'CreateqnaDto' is not assignable to parameter of type 'Omit<qna, "id" | "createdAt" | "updatedAt">'. 13 return this.qnaRepository.create(createqnaDto); [8:07:08 PM] Found 1 error. Watching for file changes. |
Beta Was this translation helpful? Give feedback.
-
Your coding conventions are so hard to understand. My dto @ApiProperty() @ApiProperty({ And in service
} |
Beta Was this translation helpful? Give feedback.
-
I found your boilerplate to be very useful. But, I'm not able to properly add a new entity, with reference to user.
Example, I want to add a new entity (id, name, userId).
Note: userId is foreign reference to user table.
I added new field through your commands given. I got generated files. Now, I want to add user reference.
I updated it in entity like this:
@manytoone(() => UserEntity, {
eager: true,
})
user?: UserEntity;
Added this in domain as:
@ApiProperty({
type: () => User,
})
user: User;
Added this in mapper.
But, Im having difficulty in DTOs.
My question is how to do changes in all three DTOs: create-qna.dtp.ts, find-all-qnas.dto.ts, update-qna.dto.ts
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions