NestJS Raw SQL문을 TypeORM에서 사용하기(typeorm@0.3.0 version이후)
기존에는 'getManager().query('[sql문]')'을 작성해서 DB에서 데이터를 받아왔습니다. 하지만 0.3.0버전 이후 getManager가 Deprecated되서 최신버전의 typeorm에서 다른방법으로 NestJS에서 쿼리문을 사용할 방법을 찾았습니다. // src/users/users.service.ts import { Injectable } from '@nestjs/common' ; import { InjectDataSource , InjectRepository } from '@nestjs/typeorm' ; import { Repository , DataSource } from 'typeorm' ; // DataSource를 사용 import { UserEntity } from './entity/user.entity' ; @ Injectable () export class UsersService { constructor ( @ InjectRepository ( UserEntity ) private readonly userEntity : Repository < UserEntity >, // DataSource를 해당 서비스에 주입한다. @ InjectDataSource () private dataSource : DataSource , ){} async getAllUsers (){ // dataSource에 쿼리문을 입력하면 바로 DB에서 해당 쿼리문의 결과가 리턴된다. return await this . dataSource . query ( `SELECT * FROM users LIMIT` ) } } 'DataSource'를 이용하여 쿼리문을 작성하면...