[NestJs, TypeORM 에러] Looks like this entity is not registered in current "default" connection?
2021. 6. 9. 14:22ㆍFrontend/JS
상황: NestJs 에서 postgresql 과 연동하는 과정에서 발생한 에러.
상황2: 아래의 Entity 파일을 db에 연동하지 못한 상황.
// contact.entity.ts
import {Column, Entity, PrimaryGeneratedColumn} from "typeorm";
export class contact{
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
@Column()
sns: string;
@Column()
phone: number;
@Column()
address: string;
}
원인: 에러 메시지를 확인하면 No repository for "Contact" was found. , 즉 Contact 레포지토리가 확인되지 않음을 알 수 있다.
해결: Contact repository 를 자동으로 생성해주는, @Entity 어노테이션을 contact 클래스에 붙여주면 된다.
@Entity()
export class contact{
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
@Column()
sns: string;
@Column()
phone: number;
@Column()
address: string;
}
'Frontend > JS' 카테고리의 다른 글
Javascript 자주 사용하는 메서드 (feat. array) (0) | 2021.07.22 |
---|---|
[NestJs, TypeORM 에러] Nest can't resolve dependencies of the "Service" (0) | 2021.06.09 |
TypeError: Cannot read property 'node' of undefined 에러 해결 (0) | 2021.05.26 |
spread 연산자와 map() 메서드 (0) | 2021.02.21 |
화살표 함수 (feat. in React) (0) | 2020.11.10 |