You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-library/utils/dorm/gorm_gen_mysql.go

23 lines
476 B

package dorm
import (
"gorm.io/driver/mysql"
"gorm.io/gen"
"gorm.io/gorm"
)
func NewGormGenMysqlClient(config *GormGenClientConfig) (*GormGenClient, error) {
c := &GormGenClient{config: config}
c.Generator = gen.NewGenerator(gen.Config{
OutPath: "../query",
Mode: gen.WithoutContext | gen.WithDefaultQuery | gen.WithQueryInterface, // generate mode
})
c.Db, _ = gorm.Open(mysql.Open(c.config.Dns), &gorm.Config{})
c.Generator.UseDB(c.Db)
return c, nil
}