Sfoglia il codice sorgente

📝 docs(entity): add common non-standard issues section

- add "常见不规范问题" section to document entity definition mistakes
- provide example of incorrect nullable field definition using optional chaining (?)
- show correct nullable field implementation with explicit null type union
yourname 4 mesi fa
parent
commit
1e334789e7
1 ha cambiato i file con 24 aggiunte e 0 eliminazioni
  1. 24 0
      .roo/rules/10-entity.md

+ 24 - 0
.roo/rules/10-entity.md

@@ -1,5 +1,29 @@
 # 数据库实体规范
 
+## 常见不规范问题
+  1. nullable 字段用了? 而不是!, 类型没加 null
+    错误示例:
+      ```ts
+      @Column({
+        name: 'description',
+        type: 'text',
+        nullable: true,
+        comment: '容器配置描述'
+      })
+      description?: string;
+      ```
+    正确示例:
+      ```ts
+      @Column({
+        name: 'description',
+        type: 'text',
+        nullable: true,
+        comment: '容器配置描述'
+      })
+      description!: string | null;
+      ```
+
+
 ## 1. 实体基础结构
 
 ```typescript