這是我的模型
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/[email protected]/migrator.go:118 錯誤:型別“string[]”不存在(SQLSTATE 42704)
uj5u.com熱心網友回復:
postgre 中沒有字串資料型別。將字串 [] 更改為文本 []
uj5u.com熱心網友回復:
這不是一個好方法。你應該為它制作一個單獨的表格
票務表:
type Ticket struct {
gorm.Model
PassengerName string `json:"passenger_name"`
Price uint64 `json:"price"`
Seat []Seat `json:"seat" gorm:"foreignKey:SeatId"` }
座位表:
type Seat struct {
gorm.Modal
SeatId serial `json:seat_id`
Seat string `json:"seat"`}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/447718.html
標籤:PostgreSQL 走 戈戈姆
