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.
23 lines
476 B
23 lines
476 B
2 years ago
|
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
|
||
|
}
|