当前位置:网站首页>nest.js入门之 database
nest.js入门之 database
2022-07-07 16:09:00 【crayon-shin-chan】
文档:https://docs.nestjs.com/techniques/database
1.简介
Nest 与数据库无关,可以轻松与任何 SQL 或 NoSQL 数据库集成。
可以直接使用任何通用的 Node.js 数据集成库或 ORM,如
- MikroORM
- Sequelize
- Knex.js
- TypeORM
- Prisma
Nest 提供了与 TypeORM 和 Sequelize 的紧密集成,分别使用
- @nestjs/typeorm
- @nestjs/sequelize
2.TypeORM
2.1 安装依赖
要开始使用它,首先安装所需的依赖项。
$ npm install --save @nestjs/typeorm typeorm mysql2
2.2 使用模块
安装完成后,把TypeOrmModule导入到 AppModule中。
@Module({
imports: [
TypeOrmModule.forRoot({
type: 'mysql',
host: 'localhost',
port: 3306,
边栏推荐
- <代码随想录二刷>链表
- Simple loading animation
- 自动化测试:Robot FrameWork框架大家都想知道的实用技巧
- Mrs offline data analysis: process OBS data through Flink job
- yolo训练过程中批量导入requirments.txt中所需要的包
- Function and usage of calendar view component
- Tips of this week 135: test the contract instead of implementation
- Win11C盘满了怎么清理?Win11清理C盘的方法
- [deep learning] 3 minutes introduction
- What are the financial products in 2022? What are suitable for beginners?
猜你喜欢
Chapter 2 building CRM project development environment (building development environment)
Ten thousand words nanny level long article -- offline installation guide for datahub of LinkedIn metadata management platform
Pro2:修改div块的颜色
手撕Nacos源码(先撕客户端源码)
zdog. JS rocket turn animation JS special effects
科学家首次观察到“电子漩涡” 有助于设计出更高效的电子产品
深度学习-制作自己的数据集
4种常见的缓存模式,你都知道吗?
Pro2: modify the color of div block
【蓝桥杯集训100题】scratch从小到大排序 蓝桥杯scratch比赛专项预测编程题 集训模拟练习题第17题
随机推荐
Functions and usage of tabhost tab
回归测试的分类
物联网OTA技术介绍
[re understand the communication model] the application of reactor mode in redis and Kafka
Year SQL audit platform
基于RGB图像阈值分割并利用滑动调节阈值
[network attack and defense principle and technology] Chapter 4: network scanning technology
Five simple ways to troubleshoot with Stace
mui侧边导航锚点定位js特效
[OKR target management] case analysis
Explain it in simple terms. CNN convolutional neural network
[paddleseg source code reading] add boundary IOU calculation in paddleseg validation (1) -- val.py file details tips
Tips for this week 134: make_ Unique and private constructors
Win11C盘满了怎么清理?Win11清理C盘的方法
Tips for this week 140: constants: safety idioms
Tips of this week 135: test the contract instead of implementation
golang 客户端服务端登录
机器人工程终身学习和工作计划-2022-
深度学习-制作自己的数据集
Use onedns to perfectly solve the optimization problem of office network