inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

묻고 답해요

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

Identifying relation 과 non-identifying relation

미해결

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

안녕하세요! 보여주신 erd에서 궁금증이 생겨서 질문 드립니다. dms의 ReciverId과 mentions의 Receiverid 만 Non-identifying relation으로 맺어져 있고 나머지 관계들은 모두 Identifying Relation으로 맺어져 있는 이유가 뭘까요? Non-Identifying Relation과 Identifying Relation의 차이는 Non의 경우는 부모와 자식의 관계를 맺을때 자식이 부모 없이도 독립적으로 존재 가능한 것이고, Identifying-Relation은 자식이 부모 없이는 존재가 불가능한 차이로 알고 있습니다. DM과 Mention의 Receiver가 존재하지 않는다면, DM과 Mention의 정보가 불완전해질 것 같은데, 왜 non-identifying 일까요? typeorm entity 코드를 봐도, DM과 User entity의 Sender와 Receiver의 코드가 완전 똑같은데, 왜 ERD에서는 Receiver는 non-identifying 이고 Sender는 identifying인지 모르겠습니다.

  • node.js
  • express
  • nestjs
  • typeorm
이민석 댓글 1 좋아요 0 조회수 484

@Get(':id') @Get('all')

해결됨

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

@Get(':id') getOneCat(@Param('id', PositiveIntPipe) id: number) { console.log(id, typeof id); return 'one cat'; } 이전에 작성되었던 아이디로 검색 메서드가 있었는데요, 이번 강의에서 @Get('all') 을 추가해서 포스트맨으로 테스트하는데 위에 getOneCat 으로 넘어가는데 왜 이런건지 알 수 있을까요? @ApiOperation({ summary: '현재 고양이 가져오가' }) @UseGuards(JwtAuthGuard) @Get() getCurrentCat(@CurrentUser() cat) { return cat.readOnlyData; } 만약 이게 더 위에 있다면, 여기서 걸린다면 이해 하겠는데 그렇지도 않고 @Get('all') 일때만 걸리는 이유가 뭘까요..?

  • node.js
  • mongodb
  • express
  • nestjs
  • ssr
게으른 개발자 댓글 1 좋아요 0 조회수 389

pm2 에러

미해결

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

ec2-ubuntu 환경에서 pm2사용하는데 sudo npm run start:prod cross-env NODE_ENV=production PORT=80 pm2 start dist/src/main.js 실행하였는데 Error: EACCES: permission denied, mkdir '/root/.pm2/logs' Error: EACCES: permission denied, mkdir '/root/.pm2/pids' Error: EACCES: permission denied, open '/root/.pm2/module_conf.json' Error: EACCES: permission denied, mkdir '/root/.pm2/modules' 에러가 발생해서 제로초님이 답변하신거 찾아보고 노드 재설치도 했는데 같은 에러가 발생합니다

  • node.js
  • express
  • nestjs
  • typeorm
devdev 댓글 1 좋아요 0 조회수 639

[ERR_ASSERTION]에러....

해결됨

[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스

안녕하세요 정말 열심히 듣고 있었지만 오류가 발생하자 아무리 찾아도 나오지 않아 답답해서 문의 드립니다. 강의: 크롤링 2 - puppeteer docker-compose up 으로 실행 하였고 crawler 를 node index.js 실행 하자 저런 에러들이 발생하였습니다.... 해결 방법이 있을까요??

  • javascript
  • node.js
  • express
  • docker
  • tdd
  • rest-api
  • nestjs
뽕리뽕뽕 댓글 1 좋아요 0 조회수 340

dist/main.js 경로

해결됨

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

Script not found: C:\Users\USER\Documents\project\linkfit-backend\dist\main.js 이렇게 에러가 나서 보니까 main.js경로가 dist/src/main.js에 있던데 이게 맞나요?

  • node.js
  • express
  • nestjs
  • typeorm
devdev 댓글 1 좋아요 2 조회수 913

상태코드 질문

해결됨

[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스

async loginUser({ email, password, context }) { const user = await this.userService.findOne({ email }); if (!user) throw new UnprocessableEntityException('이메일이 없습니다.'); const isAuth = bcrypt.compare(password, user.password); if (!isAuth) throw new UnprocessableEntityException('비밀번호가 틀렸습니다.'); await this.setRefreshToken({ user, res: context.res }); return await this.setAccessToken({ user, res: context.res }); } 이렇게 아이디 비번이 다를때 오류 처리를 해주었는데 client에 넘어가는 status코든는 200이 뜨네요 왜 그럴까요?

  • javascript
  • node.js
  • nestjs
h0ng 댓글 1 좋아요 0 조회수 422

mongo설치 오류

해결됨

[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스

안녕하세요 지금까지 열심히 듣고 있습니다. 다름이 아니라 몽고 db 설치에서 문제가 생겨 여쭈어 보려고 합니다. brew services start mongodb-community 실행시 아래와 같은 오류가 발생합니다. 해결방법이 있을까요??.... (맥북m1)

  • javascript
  • node.js
  • express
  • docker
  • tdd
  • rest-api
  • nestjs
댓글 0 좋아요 0 조회수 326

google cloud storage의 keFilename

해결됨

[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스

안녕하세요. fileUpload시 google cloud storage의 keyFilename 내용을 읽지 못하는듯 합니다. 코드는 하기와 같고요. 실행시 아래와 같은 오류가 발생 합니다. 경로 문제 일까요?

  • javascript
  • node.js
  • express
  • docker
  • tdd
  • rest-api
  • nestjs
Walter 댓글 1 좋아요 0 조회수 474

이미지 업로드 API - graphql postman uploadFile 시 headers 문제

해결됨

[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스

안녕하세요. '이미지 업로드 API' 수업 따라가다 Postman으로 'uploadFile' 호출시 'Cross-Site Request Forgery(CSRF)' 오류 발생에 대해서 확인 후 원인에 대해서 시원한 답변 부탁 드릴께요. 위와 같이 CSRF 오류가 발생 합니다. 구글후 headers에 하기 값을 추가하니 문제 없네요. 원인에 대해서 쉽게 설명좀 부탁 드립니다. :)

  • node.js
  • express
  • rest-api
  • nestjs
Walter 댓글 2 좋아요 0 조회수 1619

command not found

해결됨

[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스

계속 yarn을 설치해도 command not found라고만 뜨는데 어떻게 하면 좋을까요

  • javascript
  • node.js
  • express
  • docker
  • tdd
  • rest-api
  • nestjs
SW 댓글 1 좋아요 0 조회수 702

Relation 테이블 관련 에러

미해결

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

Movie, User 테이블하고 many-to-many 로 만든 Favorite 테이블이 있는데 Favorite 테이블에 저장하려고 할 때 이런 에러가 납니다. query failed: INSERT INTO `favorite`(`id`, `userId`, `movieId`) VALUES (DEFAULT, DEFAULT, DEFAULT) error: Error: Unknown column 'id' in 'field list' query: ROLLBACK [Nest] 782975 - 04/08/2023, 6:59:26 PM ERROR [ExceptionsHandler] Unknown column 'id' in 'field list' Movie 는 이렇게 만들어져있구요 import { Entity, Column, PrimaryGeneratedColumn, ManyToMany, JoinTable } from 'typeorm'; import { User } from '../users/users.entity'; @Entity() export class Movie { @PrimaryGeneratedColumn() readonly id: number; @Column({ length: 100 }) title: string; @Column('text', { nullable: true }) desc: string; @ManyToMany(() => User, (user) => user.favorites) @JoinTable({ name: 'favorite' }) favorites: User[]; } User 는 import { Entity, Column, PrimaryGeneratedColumn, ManyToMany, JoinTable } from 'typeorm'; import { Movie } from '../movies/movies.entity'; @Entity() export class User { @PrimaryGeneratedColumn() readonly id: number; @Column() username: string; @ManyToMany(() => Movie) @JoinTable({ name: 'favorite' }) favorites: Movie[]; } 그리고 Favorite 은 import { Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'; import { User } from '../users/users.entity'; import { Movie } from '../movies/movies.entity'; @Entity() export class Favorite { @PrimaryGeneratedColumn() id: number; @ManyToOne(() => User, (user) => user.favorites) user: User; @ManyToOne(() => Movie, (movie) => movie.favorites) movie: Movie; } 그런데 DB 를 보면 Favotie 테이블에 id 칼럼이 없습니다. 그래서 favoriteRepository.save() 할때 에러가 난다고 의심하고 있는데요, favorites.service.ts는 import { Injectable } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { Repository } from 'typeorm'; import { Favorite } from './favorites.entity'; @Injectable() export class FavoritesService { constructor( @InjectRepository(Favorite) private readonly favoriteRepository: Repository<Favorite>, ) {} async create(userId: number, movieId: number): Promise<Favorite> { const favorite = new Favorite(); favorite.user = { id: userId } as any; favorite.movie = { id: movieId } as any; return await this.favoriteRepository.save(favorite); } } 이렇게 되어있습니다. 어디를 고쳐야 하는걸까요?

  • node.js
  • express
  • nestjs
  • typeorm
ii 댓글 1 좋아요 0 조회수 508

bad CPU type in executable: docker-credential-gcr

해결됨

[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스

배포 사전 학습과제 진행중에, gcloud로 docker-credential-gcr 설치 gcloud components install docker-credential-gcr docker-credential-gcr 이용 docker-credential-gcr configure-docker 를 입력했을 때 제목과 같이 bad CPU 에러가 발생합니다. 이유를 알고싶습니다. (경로 확인 which docker-credential-gcr 했을 때 /Users/paradise/Desktop/google-cloud-sdk/bin/docker-credential-gcr 라고 확인됩니다.) (파일 executable 확인 file docker-credential-gcr 했을 때 docker-credential-gcr: Mach-O 64-bit executable arm64 라고 확인됩니다.) ingress 설정중에 발생한 문제가 있습니다. ingress 를 만들기 전에 이미지를 새로 만들고 gcloud shell에서 set image를 통해 재배포하는 단계까지는 모두 성공적으로 작동합니다. 다만 ingress를 만들면 404, cannot get error 가 발생합니다. All backend services are in UNHEALTHY state 라고 나옵니다. 이유가 궁금합니다.

  • javascript
  • node.js
  • express
  • docker
  • tdd
  • rest-api
  • nestjs
댓글 0 좋아요 0 조회수 437

getCurrentCat 에서 req.user

해결됨

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

req.user 에서, request 가 user 객체 정보를 가지고 있는 건가요..? -- 확인해 보니, passport 에서 User 인터페이스를 가지고 있네요! 그런데, 비어있는데 어떻게 속성을 가지고 있는 걸까요? JwtStrategy/validate 의 리턴값을 가지게 되는 건가요? 3월 14일 질문에 대한 답변도 좀 부탁 드립니다..

  • node.js
  • mongodb
  • express
  • nestjs
  • ssr
게으른 개발자 댓글 1 좋아요 0 조회수 634

순환참조

미해결

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

user와 auth가 서로를 import하고 있어서 forwardRef로 순환 참조를 막아줬는데 auth에선 userRepository를 사용하고 있고 user에선 authService.jwtLogin()을 사용하는데 순환 참조가 발생하는 건가요? 안 막아줘도 되는건가요?

  • node.js
  • mongodb
  • express
  • nestjs
  • ssr
한승보 댓글 1 좋아요 0 조회수 481

질문드립니다.

미해결

타입스크립트의 모든 것

클래스 - readonly 와 생성자 이 수업에서 타임라인 28초쯤부터 ~ 1분 13초쯤까지 어떨 때는 정보를 보낼 때 class를 쓰고 어떨 때는 json과 object를 쓴다고 예를 들어주시는 내용 같은데.. 말이 좀 엉켜서 제가 이해가 잘 안되네요 😥 다시 한번 설명 좀 부탁드려도 될까요?

  • typescript
  • nestjs
alice 댓글 1 좋아요 0 조회수 284

UpdateValuesMissingError

해결됨

[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스

import { Injectable } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { Repository } from 'typeorm/repository/Repository'; import { User } from '../users/entities/user.entity'; import { Payment, POINT_TRANSACTION_STATUS_ENUM, } from './entities/payment.entity'; @Injectable() export class PaymentService { constructor( @InjectRepository(Payment) private readonly paymentRepository: Repository<Payment>, @InjectRepository(User) private readonly userRepository: Repository<User>, ) {} async create({ impUid, amount, currentUser }) { const pointTransaction = await this.paymentRepository.create({ impUid, amount, user: currentUser, status: POINT_TRANSACTION_STATUS_ENUM.PAYMENT, }); await this.paymentRepository.save(pointTransaction); const user = await this.userRepository.findOne({ id: currentUser.id }); console.log(amount); await this.userRepository.update( { id: user.id }, // where { point: user.point + amount }, ); return pointTransaction; } } payment 과제 중 payment.service.ts 코드입니다. 결제는 문제없이 처리가 되었고, payment 테이블에 거래기록이 저장되어야 하는데 이러한 에러가 발생합니다. [Nest] 288 - 03/29/2023, 7:34:01 AM ERROR [ExceptionsHandler] Cannot perform update query because update values are not defined. Call "qb.set(...)" method to specify updated values. 여러 시도를 해봤지만 해결되지 않아 커뮤니티에 글 남깁니다!

  • javascript
  • node.js
  • express
  • docker
  • tdd
  • rest-api
  • nestjs
songin cheon 댓글 1 좋아요 0 조회수 980

prisma timezone에 관한 질문이 있습니다.

미해결

Node.js의 모든 것

현재 공식 레퍼런스를 보며 prisma, next를 사용해서 게시판을 만드는 프로젝트 작업을 성공적으로 끝냈지만 한가지 문제가 있었습니다. prisma의 now()가 timezone UTC를 베이스로 작동하고 있는데 이걸 설정하는 방법을 prisma에서 공식적으로 지원하지 않는다고 검색을 통해 알게되었습니다. 아직 강의 내용을 수강하지는 않았기에 강의내용에서 timezone 관련 이슈를 다루는지는 모르겠지만 그 파트를 직접 찾기에는 오래 걸리는터라.... 먼저 질문부터 남겨봅니다.

  • postgresql
  • nestjs
  • prisma
  • mysql
edu1 댓글 1 좋아요 0 조회수 3377

일반적인 ORM 사용패턴(DDL, DML) 문의

미해결

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

수업에서는 기존 DB라 typeorm-model-generator를 사용했는데요, 저의 질문의 요점은 ORM으로 DML 위주의 사용이 보편적인가 하는 것입니다. 제가 python하다가 node.js로 넘어와서, python 예를 들어 죄송합니다만, https://velog.io/@youngkiu/SQLAlchemy-with-DDL python에서는 model도 create table sql로 만들지 않고, model을 생성하고, ORM에서 DDL 처리도 같이 해주었습니다. 스프링에서도 DDL은 ORM을 사용하지 않고, DB에서 직접 처리한다는 이야기를 듣기도 하여, 업계에서 ORM의 일반적인 사용방법이 궁금하여 질문드립니다. 늘 많이 배우고 있습니다. 감사합니다. 타입스크립트 책 얼릉 출간해 주세요. 바로 구매하겠습니다.

  • node.js
  • express
  • nestjs
  • typeorm
유영기 댓글 2 좋아요 0 조회수 920

unexpected end of input

해결됨

[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스

console.log("안녕하세요, 문자 인증번호 보내드립니다.") function createTokenOfPhone(myphone){ if(myphone.length !== 10 && myphone.length !== 11){ console.log("에러 발생! 핸드폰 번호를 제대로 입력해 주세요. ") return } const aaaa=6 if(aaaa === undefined){ console.log("에러 발생!!! 갯수를 제대로 입력해 주세요!!!") return } else if(aaaa <= 0){ console.log("에러 발생!! 갯수가 너무 적습니다!!") return }else if(aaaa > 10){ console.log("에러 발생!!! 갯수가 너무 많습니다!!!") return } const result = String(Math.floor(Math.random() * 10 ** aaaa)).padStart(aaaa,"0") console.log(result) console.log(myphone+ "번호로 인증번호" +result+ "를 전송합니다!!!") createTokenOfPhone("01012341234") 수업과 동일하게 코드를 작성했으나 아래와 같은 에러가 뜹니다. (base) c@Dui-c-G9C7V6620L 01-01-token % node index.js /Users/c/Desktop/codecamp-backend-03./class/01-01-token/index.js:25 createTokenOfPhone("01012341234") SyntaxError: Unexpected end of input at internalCompileFunction (node:internal/vm:73:18) at wrapSafe (node:internal/modules/cjs/loader:1176:20) at Module._compile (node:internal/modules/cjs/loader:1218:27) at Module._extensions..js (node:internal/modules/cjs/loader:1308:10) at Module.load (node:internal/modules/cjs/loader:1117:32) at Module._load (node:internal/modules/cjs/loader:958:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:23:47

  • javascript
  • node.js
  • express
  • docker
  • tdd
  • rest-api
  • nestjs
SW 댓글 1 좋아요 0 조회수 1012

dto 와 entity의 유지보수

미해결

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

안녕하세요. 상석님! 상석님의 강의를 듣고 공식문서와 typeorm, mongoose등의 공식문서를 함께 이용하여 nest 프로젝트를 제작중인 1년차 node js 개발자입니다. 강의 너무 잘 들었습니다. 개인적으로 프로젝트를 진행하는 중 dto파일과 entity를 어떻게 관리하면 수월할까 라는 고민을 깊게 하게 되었습니다. chat gpt나 스택오버 플로우, 구글 등 많은 검색을 해봤지만 제 실력이 부족한지 정보를 찾기가 힘들어 여쭤보게 되었습니다. export class CreateRequestPostDto { @ApiProperty({ example: 'youtube uri', name: 'youtubeUri' }) @IsUrl() uri: string; @ApiProperty({ example: 'postTitle writed for user' }) @IsString() postTitle: string; @ApiProperty({ example: 'postDescription writed for user' }) @IsString() postDescription: string; } export class UpdatePostDto { @ApiProperty({ example: 'postTitle writed for user' }) @IsString() postTitle: string; @ApiProperty({ example: 'postDescription writed for user' }) @IsString() postDescription: string; } 위는 제가 만들고 있는 프로젝트의 일부입니다. postTitle과 postDescription이 두 클래스에서 중복이 되는 케이스인데 상속을 이용해서 postTitle과 postDescription을 따로 빼는 방법은 제가 원하는 방향이 아닙니다. 저는 기본적인 base dto클래스를 하나 만들어 놓고 이를 재활용하는 방법을 사용하고 싶습니다. export class BasePostClass { @ApiProperty({ example: 'youtube uri', name: 'youtubeUri' }) @IsUrl() uri: string; @ApiProperty({ example: 'postTitle writed for user' }) @IsString() postTitle: string; @ApiProperty({ example: 'postDescription writed for user' }) @IsString() postDescription: string; } 만약 위와 같은 클래스가 있다면 이를 이용해서 export class uriPostClass { uri: 위의 BasePostClass에 있는 uri 프로퍼티만을 가져와서 이 곳에서 사용하고 싶습니다. } 이와 같이 @ApiProperty 데코레이터를 다시 적어주지 않아도 되고 BasePostClass의 프로퍼티 하나를 바꾸면 이 클래스를 이용해 다른 클래스들에 영향을 주고싶은겁니다. uri라는 이름을 URI로 변경하면 이 다른 클래스에서도 영향을 받아 URI로 변한다거나 하다못해 서버 실행 과정에서 에러라도 발생시킬 수 있도록 하고싶습니다. 프로젝트가 커지다보니 DTO파일을 관리하기도 쉽지 않았어요. db의 컬럼 이름을 하나 바꿔주면 여기저기 dto파일을 찾아다니며 같이 바꿔줘야 했습니다. 좋은 방법이 있다면 알려주실 수 있을까요?

  • node.js
  • mongodb
  • express
  • nestjs
  • ssr
qwe980121 댓글 1 좋아요 1 조회수 837

인기 태그

인프런 TOP Writers

주간 인기글