目录
模型关联与树形嵌套
学习目标
这次教程在上一节的基础上实现一个简单的CMS系统,实现如下功能
- 文章与分类多对多关联
- 文章与评论一对多关联
- 分类与评论的树形无限级嵌套
文件结构
这次的更改集中于ContentModule
模块,编写好之后的目录结构如下
src/modules/content
├── content.module.ts
├── controllers
│ ├── category.controller.ts
│ ├── comment.controller.ts
│ ├── index.ts
│ └── post.controller.ts
├── dtos
│ ├── create-category.dto.ts
│ ├── create-comment.dto.ts
│ ├── create-post.dto.ts
│ ├── index.ts
│ ├── update-category.dto.ts
│ └── update-post.dto.ts
├── entities
│ ├── category.entity.ts
│ ├── comment.entity.ts
│ ├── index.ts
│ └── post.entity.ts
├── repositories
│ ├── category.repository.ts
│ ├── comment.repository.ts
│ ├── index.ts