
GORM自定义数据类型的集合
5星
- 浏览量: 0
- 大小:None
- 文件类型:None
简介:
本篇文章介绍了如何在Go语言的GORM框架中实现和使用自定义的数据类型。涵盖了必要的配置步骤及应用实例,帮助开发者灵活处理特定需求的数据模型。
GORM数据类型JSON格式在sqlite、mysql、postgres中的使用方式如下:
```go
import gorm.io/datatypes
type UserWithJSON struct {
gorm.Model
Name string
Attributes datatypes.JSON
}
DB.Create(&User{
Name: json-1,
Attributes: datatypes.JSON([]byte(`{name: jinzhu, age: 18, tags: [tag1, tag2]`)),
})
```
全部评论 (0)
还没有任何评论哟~


