Answer the question
In order to leave comments, you need to log in
How to use jsonb (PostgreSQL) in Gorm in golang?
I decided to store the information in a field like jsonb(PostgreSQL) .
How to work with such fields in golang?
You need to write down the values and make a selection. Or just insert SQL code?
Answer the question
In order to leave comments, you need to log in
To auto-create a field with the required data type, you need to put a tag describing the type:
If you need a JSONB data type in Go itself, you can look here:
Gorm JSONB
I use GORM and this helped me:
https://github.com/jinzhu/gorm/issues/516
Plus this
type ClassRoom struct {
gorm.Model
State string `sql:"type:JSONB NOT NULL DEFAULT '{}'::JSONB"`
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question