update llm.txt
This commit is contained in:
@@ -218,6 +218,15 @@ type UserStatus string
|
||||
Common types:
|
||||
|
||||
- JSON: `types.JSON`, `types.JSONMap`, `types.JSONType[T]`, `types.JSONSlice[T]`
|
||||
|
||||
### 2.4 JSONB 强类型规则(`types.JSONType[T]`)
|
||||
|
||||
- 如果某个 `jsonb` 字段的数据结构是“确定且稳定”的,优先将 `types.JSON` 升级为 `types.JSONType[fields.TableNameFieldName]`,以获得类型约束与更清晰的读写代码。
|
||||
- `fields.TableNameFieldName` 必须定义在 `backend/database/fields/[table_name].go` 中,格式为 `type TableNameFieldName struct { ... }` 并为每个字段写好 `json` tag。
|
||||
- 如果数据结构“不确定/随业务演进/允许任意键”,继续使用 `types.JSON`(不要强行 JSONType,以免丢字段或引入频繁迁移)。
|
||||
- 服务层读写 `types.JSONType[T]`:
|
||||
- 读取:`v := model.Field.Data()`
|
||||
- 修改:`model.Field.Edit(func(v *T) { ... })` 或 `model.Field.Set(newValue)`
|
||||
- Array: `types.Array[T]`
|
||||
- UUID: `types.UUID`, `types.BinUUID`
|
||||
- Date/Time: `types.Date`, `types.Time`
|
||||
|
||||
Reference in New Issue
Block a user