我正在嘗試使用 Postgres 連接與 golang 中的 gorm 查詢并獲取所有數據。我的戈爾姆模型 type WebsiteSlots struct { Id uint `gorm:"primary_key"` Settings string `gorm:"json"` AdsizeId int `gorm:"type:int"` WebsiteId int `gorm:"type:int"` AdSize Adsizes `gorm:"foreignkey:AdSizesId"` Website Websites `gorm:"foreignkey:WebsiteId"` UpdatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP"` CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP"`}func (WebsiteSlots) TableName() string { return "website_ads"}我的查詢存儲庫 GetSlots() 正在生成“從“website_ads”中選擇*,其中“website_ads”?!癷d”= 2 LIMIT 50 OFFSET 0”這個查詢。我不知道這個“”website_ads”.“id”= 2”是怎么來的?type Slots struct { Container *container.Container}func (w *Slots) GetSlots(skip int , limit int) []models.WebsiteSlots { var results []models.WebsiteSlots sites := w.Container.Get("dbprovider").(*services.Database) postgresConnection := sites.PostgresConnection() postgresConnection.LogMode(true) var websiteslots models.WebsiteSlots resp, _ := postgresConnection.Debug().Find(&websiteslots).Limit(limit).Offset(skip).Rows() //i := 0 for resp.Next() { results = append(results,websiteslots) } return results}有人可以幫忙嗎?
添加回答
舉報
0/150
提交
取消