인프런 커뮤니티 질문&답변
UpdateValuesMissingError
해결된 질문
작성
·
938
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.
여러 시도를 해봤지만 해결되지 않아 커뮤니티에 글 남깁니다!
답변 1
0
노원두
지식공유자
안녕하세요! songin cheon 님!
위의 에러는 보통 일반적으로 update 구문에 무엇을 업데이트 할 것인지 적어주지 않았을 때 발생합니다!
위의 코드에서 업데이트와 관련된 부분은 가장 아래쪽 부분인 것 같아요!
저장이 안 되어있거나, 해당 부분이 빠져있는 경우 발생 가능한 예제 상황을 첨부드립니다!
위의 스크린샷 만으론 전체 파일을 볼 수 없는 상황이기에, 파일 저장 상태를 확인해 보아야 할 것 같습니다!







