inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

묻고 답해요

176만명의 커뮤니티!! 함께 토론해봐요.

nested json을 dto로 전달하려면 어떻게 해야하나요?

미해결

따라하며 배우는 NestJS

1개의 json 객체 안에 프로퍼티가 다른 여러 객체들이 들어있는 리스트가 담겨있는 것을 dto로 전달하려면 어떻게 해야하나요? 구글링해보니까 nested 인터페이스를 사용하기도 하던데, Entity는 일반적으로 class로 만드니까 nested class는 어떻게 생성하는지가 궁금합니다. 그리고 제 목표는 저 json 인에 들어있는 2가지 종류의 객체( slider type과 selecrive type)를 1번의 post메소드로만 보내고 싶습니다. 그런데 아래처럼 두 객체의 프로퍼티가 다를때, 하나의service,controller,repository를 이용해서 전달하려면 어떻게 해야하나요? json 객체의 형태는 아래와 같습니다. { "questions_count": 8, "results_slider": [ { "type": "slider", "main_criteria_id": 0, "main_criteria": "Mollit mollit qui sint irure do ad laborum quis ullamco eu dolor.", "sub_criterias": [ "Eu occaecat pariatur sunt duis amet in sint velit amet consequat deserunt.", "Culpa Lorem nisi ut ea irure et eu do cupidatat ipsum duis veniam elit." ], "results": [ { "sub_criteria_id": 0, "sub_criteria_score": 4.7748 }, { "sub_criteria_id": 1, "sub_criteria_score": 7.091 } ] }, { "type": "slider", "main_criteria_id": 1, "main_criteria": "Qui consequat ullamco aliquip Lorem minim commodo irure magna cillum.", "sub_criterias": [ "Velit eu ullamco id nisi quis consequat non non commodo aliquip qui mollit.", "In esse amet proident dolore do aliquip est deserunt commodo eu eiusmod cillum.", "Nisi laboris velit Lorem irure." ], "results": [ { "sub_criteria_id": 0, "sub_criteria_score": 8.1561 } ] } ], "results_selective": [ { "type": "selective", "selective_criteria_id": 0, "selective_criteria": "Aute veniam quis adipisicing sint est amet aliquip elit.", "results": [ { "option_id": 0, "option_score": 3 }, { "option_id": 1, "option_score": 4 }, { "option_id": 2, "option_score": 5 }, { "option_id": 3, "option_score": 2 } ] }, { "type": "selective", "selective_criteria_id": 1, "selective_criteria": "Ipsum culpa dolore ad culpa amet aute ad.", "results": [ { "option_id": 0, "option_score": 3 } ] } ] }

  • typescript
  • postgresql
  • nestjs
  • nested
  • TypeORM
  • jwt
  • nestedjson
  • NestJS
  • nestedclass
서가원 댓글 0 좋아요 0 조회수 490

common entity 상속 시 컬럼 순서 문제

미해결

탄탄한 백엔드 NestJS, 기초부터 심화까지

안녕하세요 typeorm 강의에서 쓰신 common entity를 상속하는 코드를 사용하면 위와 같이 컬럼 순서가 나오는데 이렇게 되면 가독성이 안좋아서 컬럼 순서를 바꿔보려 했습니다. 검색해보니 엔티티를 상속했을때 컬럼 순서를 바꿀수 없다고 합니다. https://www.mrlatte.net/code/2020/11/03/typeorm-entity-inheritance.html 실무에서는 어떻게 사용하시는지 궁금합니다.

  • typeorm
  • nestjs
  • ssr
  • entity
  • NestJS
  • mongodb
  • inheritance
  • nodejs
  • express
wnl1012 댓글 1 좋아요 1 조회수 559

핫 리로딩 질문

미해결

Slack 클론 코딩[백엔드 with NestJS + TypeORM]

제로초님의 강의를 듣고 혼자 nestjs 개인 프로젝트를 해보려고 개발환경을 세팅하였습니다. 좋은강의 너무 감사드립니다. 세팅을 하던 중 핫 리로딩이 되지 않아 질문드립니다. nestjs 공식문서를 보고 핫 리로딩을 설정하였고, 파일을 수정하면 Error: No such label 'emitAssets' for WebpackLogger.timeEnd() 위와같은 에러가 나오며 실행이 종료됩니다. \Desktop\projects\github_visualization\backend\node_modules\webpack\lib\logging\Logger.js:123 throw new Error(`No such label '${label}' for WebpackLogger.timeEnd()`); 검색을 해보니 webpack 플러그인 문제라고 하는데, 해결 방법을 모르겠어서 질문드립니다.

  • nestjs
  • nodejs
  • hot-reloading
  • express
  • TypeORM
  • NestJS
bemodesty306 댓글 2 좋아요 0 조회수 477

NestJs, Apollo Federation 관련 질문 입니다.

미해결

Slack 클론 코딩[백엔드 with NestJS + TypeORM]

nestjs를 리용하여 microservice를 만들고 있는데 gateway를 통하여 하위앱들에 접근하고 있습니다. applications- app에서 정의한 스키마 schoolyear.entity.ts를 users-app, students-app등 다른 여러 app 들에서 사용하려고 합니다. //application-app @ObjectType() @Directive( '@key(fields: "school_year_id, date_begin, date_end")', ) @Entity({ name: 'mth_schoolyear' }) export class SchoolYear extends BaseEntity { @Column() @Field(() => ID, { nullable: true }) @PrimaryGeneratedColumn() school_year_id?: number; @Column() @Field(() => Date, { nullable: true }) date_begin: Date; @Column() @Field(() => Date, { nullable: true }) date_end: Date; } //users-app @ObjectType() @Directive('@extends') @Directive( '@key(fields: "school_year_id , date_begin, date_end")', ) @Entity({ name: 'mth_schoolyear' }) export class SchoolYear extends BaseEntity { @Column() @Field(() => ID, { nullable: true }) @PrimaryGeneratedColumn() @Directive('@external') school_year_id?: number; @Column() @Field(() => Date, { nullable: true }) @Directive('@external') date_begin: Date; @Column() @Field(() => Date, { nullable: true }) @Directive('@external') date_end: Date; } //students-app @ObjectType() @Directive('@extends') @Directive( '@key(fields: "school_year_id , date_begin, date_end")', ) @Entity({ name: 'mth_schoolyear' }) export class SchoolYear extends BaseEntity { @Column() @Field(() => ID, { nullable: true }) @PrimaryGeneratedColumn() @Directive('@external') school_year_id?: number; @Column() @Field(() => Date, { nullable: true }) @Directive('@external') date_begin: Date; @Column() @Field(() => Date, { nullable: true }) @Directive('@external') date_end: Date; } 1. @Directive(@key(fields)) 와 @Directive('@external') 사이에 어떤 관계가 있는지? @Directive('@external')가 정의된 모든 field를 @Directive(@key(fields))에 정의해야 합니까? 2. Users-app에서 정의한 external field "date_begin", "date_end"가 stuents-app에도 중복존재하는데 오유가 아닙니까?

  • apollo
  • federation
  • express
  • nodejs
  • nestjs
  • NestJS
  • directive
  • TypeORM
Cheng Wan 댓글 1 좋아요 0 조회수 443

mvc패턴을 사용한 예제를 볼 수 있는곳이 있나요?

미해결

탄탄한 백엔드 NestJS, 기초부터 심화까지

공식문서에서는 SSR방식을 사용한다고 하셨는데, CSR을 사용하는 방식과, MVC패턴을 사용한, 사용하지 않은 코드를 보면서 차이를 보고 싶습니다 예제 사이트와 코드는 어디서 찾을 수 있나요?

  • mvc
  • nestjs
  • ssr
  • NestJS
  • express
  • nodejs
  • mongodb
Ho Kim 댓글 1 좋아요 1 조회수 369

Comments Module에서 DB import를 하지않아도 상관없나요?

해결됨

탄탄한 백엔드 NestJS, 기초부터 심화까지

@Module({ imports: [MongooseModule.forFeature([{ name: Cat.name, schema: CatSchema }])], controllers: [CatsController], providers: [CatsService], }) Cat Module 에서는 위와 같이 import를 해줬는데 Comment Module에서는 import를 하나 안 하나 정상적으로 동작합니다 왜 Comment Module에서는 안 하신건가요?

  • nestjs
  • mongodb
  • express
  • nodejs
  • ssr
  • NestJS
Ho Kim 댓글 1 좋아요 1 조회수 297

swagger용 데코레이터 작성 방법

미해결

탄탄한 백엔드 NestJS, 기초부터 심화까지

swagger를 위한 정보를 decorator를 통해 추가하다보면 ApiOperation 뿐만 아니라 ApiBody, ApiResponse 등 다양한 decorator가 추가되고 이에 대한 인자를 객체로 만들어서 넣어주는 과정에서 코드가 굉장히 지저분해지고, decorator에 들어가는 객체들에 대한 정보 관리가 어려워 지는 거 같습니다 . 이런 경우에 커스텀 데코레이터를 만들어서 하나로 합쳐서 사용하고 싶은데 이러한 커스텀 테코레이터에 대해서 간단하게 작성방법을 강의영상으로 추가해주실 수 있을 지 문의 드립니다.

  • nestjs
  • swagger
  • NestJS
  • decorator
  • ssr
  • nodejs
  • mongodb
  • express
DoJin You 댓글 1 좋아요 1 조회수 623

CQRS 패턴과 gql 강의 요청

미해결

탄탄한 백엔드 NestJS, 기초부터 심화까지

혹시 NESTJS의 CQRS 패턴과 graphql(with dataloader and federation) 강의도 해주실 수 있나요??

  • nestjs
  • mongodb
  • cqrs
  • nodejs
  • express
  • NestJS
  • ssr
support 댓글 1 좋아요 1 조회수 223

안녕하세요 :) 스웨거 관련 질문이 있습니다!

미해결

탄탄한 백엔드 NestJS, 기초부터 심화까지

- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 안녕하세요 :) 강의해 주신 내용을 기반으로 소켓을 이용한 실 서비스를 구현해 보고 있는데요. 다름이 아니라 소켓 부하 테스트를 해보니 처리 못하는 요청 건수가 많아, NodeJS에서 기본적으로 제공해 주는 프로파일링을 해보았고, 그 결과 스웨거 프레임워크가 상당히 많은 CPU 리소스를 잡고 있는 것을 확인했습니다. (물론 사용 중인 AWS EC2의 사양이 낮기도 합니다.) 강의 중에 스웨거 다소 무겁다고 하셨었는데.. 실제로 체감해 보니, 스웨거가 왜 이렇게 많은 CPU를 차지하는 지, 그리고 강사님께서는 왜 무겁다고 하셨는 지 근본적인 원인이 궁금해졌습니다! 스웨거 단점을 인터넷에 찾아보니 무겁다는 측면에 대해서는 크게 언급이 없어 여기에 질문을 남깁니다! 최대한 기술적인 측면에서 답변을 해주시면 정말 감사하겠습니다!

  • nestjs
  • swagger
  • express
  • mongodb
  • nodejs
  • NestJS
  • ssr
몽우기 댓글 1 좋아요 1 조회수 468

글과 댓글 매칭 부분이 되지 않습니다. populate

미해결

탄탄한 백엔드 NestJS, 기초부터 심화까지

cat 대신하여 dog로 저는 따라 작성하였습니다. docs 페이지에 정의 되어 있습니다. postman으로 get 방식으로 dog/all로 호출 하였을때 comments schema가 등록이 안되었다고 되어 있는데 git 코드와 비교 해보면 다른점이 없어보여 질문드립니다. 출력해주는 에러에서는 [Nest] 26612 - 2021. 10. 15. 오후 3:33:29 ERROR [ExceptionsHandler] Schema hasn't been registered for model "comments". Use mongoose.model(name, schema) export class DogRepository { constructor (@ InjectModel ( Dog . name ) private readonly dogModel : Model < Dog >) {} async findAll () { console . log ( 'findAll function' ); const CommentsModel = mongoose . model ( 'comments' , CommentsSchema ); console . log ( CommentsModel ); const result = await this . dogModel . find () . populate ( 'comments' , CommentsModel ); console . log ( result ); return result ; } 와 같이 추가되었습니다. 다만 populate이부분을 사용 안하면 정상 작동하나 두 collection의 join은 되지 않습니다. 혹시 에러 원인을 파악할수 있는 부분이나 제가 check해야될 부분이 있을까요?? 다른기능은 정상 작용 중입니다.

  • nestjs
  • ssr
  • NestJS
  • express
  • mongodb
  • nodejs
dydrms444 댓글 2 좋아요 1 조회수 335

save()로 저장하고 id값을 리턴받아서 update를 하고 싶습니다.

미해결

Slack 클론 코딩[백엔드 with NestJS + TypeORM]

안녕하세요 nest+typeORM으로 공부를 하고 있습니다. 특정 테이블에 save()로 저장을 하고 리턴값으로 id값을 받아와서 특정 필드에 저장을 할 수 있는 방법이 있을까요? 이렇게 할려면 따로따로 구현을 해야하는지 아니면 한번에 구현을 할 수 있는 방법이 있는지 궁금합니다.

  • save
  • express
  • typeorm
  • nodejs
  • nestjs
  • TypeORM
  • NestJS
인프러너 댓글 1 좋아요 0 조회수 274

인기 태그

인프런 TOP Writers

주간 인기글