go-gorm

[]string to jsonb with Gorm and postgres

大兔子大兔子 提交于 2020-11-29 03:12:31
问题 I have a Go struct which contains a slice of strings which I'd like to save as a jsonB object in Postgres with GORM. I've come accross a solution which requires to use the GORM specific type (postgres.Jsonb) which I'd like to avoid. When I try to run the AutoMigrate with a slice in my model, it panics and won't start although when I wrap this slice in a struct (which I'm okay doing) it will run without error but won't create the column in postgres. type User struct { gorm.Model Data []string