摘要: import "gorm.io/datatypes" type UserWithJSON struct { gorm.Model Name string Attributes datatypes.JSON } DB.Create(&User{ Name: "json-1", Attributes: 阅读全文
posted @ 2021-12-17 11:25 hubb 阅读(142) 评论(0) 推荐(0) 编辑
摘要: Scanner / Valuer 自定义的数据类型必须实现 Scanner 和 Valuer 接口,以便让 GORM 知道如何将该类型接收、保存到数据库 type JSON json.RawMessage // 实现 sql.Scanner 接口,Scan 将 value 扫描至 Jsonb fun 阅读全文
posted @ 2021-12-17 11:19 hubb 阅读(217) 评论(0) 推荐(0) 编辑