TIL

23/12/16 TIL __ An operation failed because it depends on one or more records that were required but not found. Record to update not found. 에러

GABOJOK 2023. 12. 16. 23:51

 

 

 

An operation failed because it depends on one or more records that were required but not found. Record to update not found. 에러

상황:  브라우저에서 테스트 후 vscode에서 테스트 중 이런 에러를 만났다. 

 

 

 

찾아보니 prisma에서 update시 수정할려고 하는 값이 존재 하지 않으면 저런 에러가 나온다고 한다. 

update 같은 경우 해당 값을 SELECT 해온다음에 UPDATE를 처리하는데
SELECT하였을때 값이 없으면 위의 에러값을 던지는 것입니다.
하지만 updateMany는 SELECT 하지 않고 바로 UPDATE를 합니다.
그래서 에러가 발생하지 않습니다. 

 

 

 

 

 

 

참고 블로그

 

https://chilldaysofmine.tistory.com/entry/prisma-update-error-An-operation-failed-because-it-depends-on-one-or-more-records-that-were-required-but-not-found-Record-to-update-not-found

 

prisma - update error : An operation failed because it depends on one or more records that were required but not found. Record t

간단요약 update 대신 updateMany를 사용하면 됩니다. "An operation failed because it depends on one or more records that were required but not found. Record to update not found. " prisma에서 update시 수정할려고 하는 값이 존재 하

chilldaysofmine.tistory.com

https://github.com/prisma/prisma/issues/10142