package models import "github.com/jinzhu/gorm" type ImageInfo struct { UserId string `json:"user_id"` Path string `json:"path"` URL string `json:"url"` } func (image *ImageInfo) Save(db *gorm.DB) error { sql := "INSERT INTO image_info(user_id, path, url) VALUES (?,?,?)" err := db.Exec(sql, image.UserId, image.Path, image.URL).Error return err }