how to define list of string on gorm model?

Issue

this is my model

type Ticket struct {
    gorm.Model

    PassengerName string         `json:"passenger_name"`
    Price         uint64         `json:"price"`
    Seat          pq.StringArray `gorm:"type:string[]" json:"seat"`
}

gorm.io/driver/postgres@v1.3.1/migrator.go:118 ERROR: type "string[]" does not exist (SQLSTATE 42704)

Solution

There’s no string data type in postgre. Change string[] to text[]

Answered By – Rahmat Fathoni

Answer Checked By – Pedro (GoLangFix Volunteer)

Leave a Reply

Your email address will not be published.