전체 글(326)
-
TypeORM 함수 with NestJS
@Injectable() export class PostsService { constructor( @InjectRepository(PostsModel) private readonly postsRepository: Repository, ) {} //... } find 다수의 데이터 가져오기 async getAllPosts() { return this.postsRepository.find(); } findOne 하나의 데이터 찾기 async getPostById(id: number) { const post = await this.postsRepository.findOne({ where: { id, }, }); if (!post) { throw new NotFoundException(); } return po..
2023.12.14 -
NestJS TypeORM 테이블 생성 with PostgreSQL
선행작업 https://muyeon95.tistory.com/311 TypeORM을 사용해 클래스기반 자동 테이블 생성을 진행해본다. 이는 TypeORM 의 기능이다. // src/posts/entities/posts.entity.ts import { Column, Entity } from 'typeorm'; @Entity() export class PostsModel { @Column() id: number; @Column() author: string; @Column() title: string; @Column() content: string; @Column() likeCount: number; @Column() commentCount: number; } 엔티티 추가 TypeOrmModule.forR..
2023.12.14 -
NestJS TypeORM 설정 및 연결 with PostgreSQL
설치 npm install @nestjs/typeorm typeorm pg typeORM 세팅 app.module.ts 에 세팅한다. import { Module } from '@nestjs/common'; import { AppController } from './app.controller'; import { AppService } from './app.service'; import { PostsModule } from './posts/posts.module'; import { TypeOrmModule } from '@nestjs/typeorm'; @Module({ imports: [ PostsModule, TypeOrmModule.forRoot({ type: 'postgres', // 데이터베이스 타..
2023.12.14 -
Docker compose 파일 작성 with PostgreSQL
설치 도커 설치는 아래 링크에서 진행할 수 있다. https://www.docker.com/products/docker-desktop/ Docker Desktop: The #1 Containerization Tool for Developers | Docker Docker Desktop is collaborative containerization software for developers. Get started and download Docker Desktop today on Mac, Windows, or Linux. www.docker.com 설치 확인 docker --version 구글에 docker hub 검색 https://hub.docker.com/ Docker Hub Container Image..
2023.12.14 -
Docker Compose 란?
docker-compose는 docker를 설치하면 같이 기본으로 딸려오는 기능이다. 조금은 다른점이 있는데 예를 들어서 컨테이너로 nestjs 프로그램을 랩핑하면 이 하나의 컨테이너를 도커에다 실행했을때 nestjs 프로그램을 설계한 대로 실행되도록 할 수 있다. 그런데 컨테이너를 엄청 많이 만들기 시작한다면? nestjs 만들고, postgreSQL도 만들고, MongoDB도 만들고 Nginx 도 만들고 Redis 도 만들고 계속 만든다면? 1개나 2개일때는 도커로 쓸만했는데 컨테이너 개수가 많아지니까 관리하기가 너무 어려워진다. 이 컨테이너들을 관리하기 위해서 나온게 kubernetes, Docker compose, Docker swarm 같은 기술이다. 이중에서 현대의 가장 중요한 기술 중 하나..
2023.12.14 -
어떤 문제를 해결하기 위해 Docker 가 등장했을까
실무에 투입되거나 취업을 하거나 하면 혼자 코딩하지 않는다. 혼자 코딩을 하더라도 이 소스 코드를 결국 클라우드 같은데다 올린다. 어딘가 서버에 올려서 다시 배포를 해야한다. 프로그램을 만들게 되면 여러 개의 컴퓨터에서 사용해야하는 상황이 온다. 여러 개의 컴퓨터에서 우리가 구동할 수 있어야 한다. 내 컴퓨터에서는 잘 되는데 작업물을 누군가에게 보내면 그 사람의 컴퓨터에서는 실행이 안되는 경우들이 있다. 환경이 다름에서 오는 같은 프로젝트가 잘 안되서 실행조차 못하거나 오랜 시간이 걸리는 상황이 많이 발생을 해서 굉장히 많은 솔루션들이 등장했다. 현대 세상에는 멀티 플랫폼이라는 문제가 있다. ex) 맥, 윈도우, 리눅스 전부다 환경이 다르다. 그렇기 때문에 각각의 플랫폼별로 무언가 설치를 하거나 환경을 ..
2023.12.14