typeORM(2)
-
NestJS, TypeORM 적용하기 (nestjs + typeorm + env)
기존에는 app.module.ts에 database 설정을 해놓고 쓰고 있었는데요. 구조 정리를 하면서 env도 사용하고 구조도 나누게 되었습니다. 처음에 사용하던 방식은 공식 문서에 나오는 방법입니다. Documentation | NestJS - A progressive Node.js framework Nest is a framework for building efficient, scalable Node.js server-side applications. It uses progressive JavaScript, is built with TypeScript and combines elements of OOP (Object Oriented Progamming), FP (Functional Programmi..
2023.02.09 -
NestJS, typeORM relation에서 다른 컬럼 이름을 사용하기
NestJS에서 typeORM을 사용해 relation을 구현하게 되었습니다. relation에 사용한 컬럼 이름은 일종의 커스텀인데 그 과정을 나누고자 합니다. Entity 저는 2개의 모델을 사용했습니다. Product 테이블에는 id, name이 있고 Month 테이블에는 id, product_id, month가 있습니다. Month 테이블에 있는 product_id가 일종의 FK입니다. (실제로 fk를 맺지는 않았습니다.) export class Product { @PrimaryGeneratedColumn() id: number; @Column() name: string; } export class Month { @PrimaryGeneratedColumn() id: number; @Column()..
2022.10.31