inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

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

UpdateValuesMissingError

해결된 질문

966

songin cheon

작성한 질문수 3

0

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

답변 1

0

노원두

안녕하세요! songin cheon 님!

 

위의 에러는 보통 일반적으로 update 구문에 무엇을 업데이트 할 것인지 적어주지 않았을 때 발생합니다!

위의 코드에서 업데이트와 관련된 부분은 가장 아래쪽 부분인 것 같아요!

 

저장이 안 되어있거나, 해당 부분이 빠져있는 경우 발생 가능한 예제 상황을 첨부드립니다!
위의 스크린샷 만으론 전체 파일을 볼 수 없는 상황이기에, 파일 저장 상태를 확인해 보아야 할 것 같습니다!

image

 

그래프 ql 문서 사용할때 느낌표 남는거 어떻게 없애나요?

0

86

2

강의 전체 소스 코드를 받고싶습니다.

0

77

2

fontawesome 사용 문의

0

80

2

소스 코드 부탁드립니다~

0

86

2

깃 레포지터리 소스

0

87

2

커리큘럼12.css 정렬 에 나오는 과제 정답알고싶어요

0

74

2

10-01 Entity TypeOrmModule.forRoot 에 entities

0

89

3

강의 버전관련 문의입니다

0

104

2

Ubuntu 설치 관련

0

62

1

schema.gql 질문 드립니다.

0

51

1

서버 재실행시 Many to Many

0

102

3

input 관련 문의

0

90

2

Rest API 보다는 graphql이 주된 내용인데

0

133

2

강의 전체 소스코드 받을수있을까요?

0

156

1

도커볼륨 마운트 관련

0

127

2

findOne 타입스크립트오류

0

109

1

http => htrtps 호출 인증서 신뢰 오류

0

356

1

self-signed certificate in certificate chain 에러 발생

0

420

1

mongoose 설치 오류

0

142

1

특정 API, 특정 IP 허용 (단일경로에 CORS 활성화)

0

284

2

08-06

0

180

3

구조랑 패턴 관련해서 질문

0

126

2

mydocker

0

129

2

coolsms statuscode 2000 인데 전송안돼는 경우 확인.

0

156

1