티스토리 뷰
라이브러리, 프레임워크/TypeORM
[TypeORM + NestJS] Entity metadata was not found 에러
dv_jamie 2022. 7. 14. 10:19에러메시지
Entity metadata for User#applications was not found. Check if you specified a correct entity object and if it's connected in the connection options.
해결
코드의 문제인 줄 알고 코드만 계속 고쳐봤었는데 파일명의 문제였다.
userPostMatching.ts => userPostMatching.entity.ts
파일명에 entity를 붙이니 해결됐다.
// database.provider.ts
import { createConnection } from 'typeorm';
export const databaseProviders = [
{
provide: 'DATABASE_CONNECTION',
useFactory: async () =>
await createConnection({
type: 'mysql',
host: '',
port: 3306,
username: '',
password: '',
database: '',
entities: ['dist/**/*.entity{.ts,.js}'],
synchronize: true,
charset: 'utf8mb4',
}),
},
];
내가 databaseProvider에서 커넥션을 생성할 때 entities: ['dist/**/*.entity{.ts,.js}'] 라고 지정했기 때문에
커스텀한 파일명 끝에 .entity{.ts,.js}를 붙여야만 했던 것
사소한 문제였다.
참고 블로그
'라이브러리, 프레임워크 > TypeORM' 카테고리의 다른 글
[TypeORM + NestJS] Unknown column 'distinctAlias.User_id' in 'field list'" 에러 (0) | 2022.07.21 |
---|---|
[TypeORM] 페이징 처리 문법 (0) | 2022.07.15 |
[TypeORM] orderBy 문법 (0) | 2022.07.12 |
[TypeORM] 여러 테이블 join 후 특정 컬럼만 가져오기(getRawMany 사용) (0) | 2022.07.05 |
[TypeORM + NestJS] 조회수 증가 쿼리 예시(기존 컬럼 값 +1) (0) | 2022.07.01 |
댓글