Skip to content

Latest commit

 

History

History
37 lines (27 loc) · 597 Bytes

README.md

File metadata and controls

37 lines (27 loc) · 597 Bytes

MySql2 Combined with nestjs

For more detail look at MySql2

@Module({
  imports: [
    NestMysql2Module.register({
      host: "localhost",
      port: 30006,
      user: "root",
      password: "example"
    })
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule { }

Then in your controller:

constructor(
    @InjectMysql()
    private readonly mysql: Mysql
  ) { }
const [result, fields] = await this.mysql.query("SELECT 1+2");