- 支持一对多/多对一关系定义并生成到 Prisma schema - 简化流程:查询关联配置根据关系自动预填 - 修复 Handlebars 模板 HTML 转义导致的乱码问题 - 修复 controller 模板缺少 Prisma 导入的问题 - 新增页面模板 (page.hbs) 生成前端页面 - 添加 FindAllParams/PaginationQueryDto 索引签名修复类型兼容 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
47 lines
1.2 KiB
Handlebars
47 lines
1.2 KiB
Handlebars
|
|
|
|
// {{chineseName}}模型
|
|
model {{pascalCase name}} {
|
|
id String @id @default(cuid(2))
|
|
{{#each fields}}
|
|
{{name}} {{prismaType this}}{{#if unique}} @unique{{/if}}
|
|
{{/each}}
|
|
{{#each manyToOne}}
|
|
{{foreignKey}} String{{#if optional}}?{{/if}}
|
|
{{name}} {{targetModel}}{{#if optional}}?{{/if}} @relation(fields: [{{foreignKey}}], references: [id])
|
|
{{/each}}
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
{{#if softDelete}}
|
|
deletedAt DateTime?
|
|
{{/if}}
|
|
{{#each oneToMany}}
|
|
|
|
// 一对多:一个{{../chineseName}}有多个{{targetModel}}
|
|
{{name}} {{targetModel}}[]
|
|
{{/each}}
|
|
|
|
@@map("{{snakeCase pluralName}}")
|
|
}
|
|
{{#if hasOneToMany}}
|
|
|
|
// ⚠️ 请在以下模型中添加外键字段:
|
|
{{#each oneToMany}}
|
|
// model {{targetModel}} {
|
|
// ...
|
|
// {{foreignKey}} String{{#if optional}}?{{/if}}
|
|
// {{backRelation}} {{pascalCase ../name}}{{#if optional}}?{{/if}} @relation(fields: [{{foreignKey}}], references: [id])
|
|
// }
|
|
{{/each}}
|
|
{{/if}}
|
|
{{#if hasManyToOne}}
|
|
|
|
// ⚠️ 请在以下模型中添加反向关联:
|
|
{{#each manyToOne}}
|
|
// model {{targetModel}} {
|
|
// ...
|
|
// {{backRelation}} {{pascalCase ../name}}[]
|
|
// }
|
|
{{/each}}
|
|
{{/if}}
|