当前位置:网站首页>nest. Database for getting started with JS

nest. Database for getting started with JS

2022-07-07 18:16:00 crayon-shin-chan

file :https://docs.nestjs.com/techniques/database

1. brief introduction

Nest Database independent , Can easily work with any SQL or NoSQL Database integration .

You can directly use any general Node.js Data integration library or ORM, Such as

  • MikroORM
  • Sequelize
  • Knex.js
  • TypeORM
  • Prisma

Nest Provided with TypeORM and Sequelize The tight integration of , Separate use

  • @nestjs/typeorm
  • @nestjs/sequelize

2.TypeORM

2.1 Installation dependency

To start using it , First install the required dependencies .

$ npm install --save @nestjs/typeorm typeorm mysql2

2.2 Using modules

After installation , hold TypeOrmModule Import to AppModule in .

@Module({
  imports: [
    TypeOrmModule.forRoot({
      type: 'mysql',
      host: 'localhost',
      port: 3306,
   
原网站

版权声明
本文为[crayon-shin-chan]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071609066371.html