首先定义2个实体 Article 和 Category是多对多的关系,一篇文章可以有多个分类,一个分类可以包含多篇文章
实体定义
import { Entity, Column, PrimaryGeneratedColumn..., ManyToMany, JoinTable, } from 'typeorm'
import { IsNotEmpty } from 'class-validator'
import { Category...type: 'text',
})
content: string
@ManyToMany((type) => Category, {
cascade: true,
})
@JoinTable...int | NO | PRI | NULL | |
+------------+------+------+-----+---------+-------+
查询分页
如果查询的字段都在...,leftJoin、 innerJoin, 就需要用到typeORM 提供的QueryBuilder
import { getManager, Repository, FindManyOptions,