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_postgresql.go

38 lines
889 B

package dorm
import (
"gorm.io/driver/postgres"
"gorm.io/gen"
"gorm.io/gorm"
)
func NewGormGenPostgresClient(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(postgres.Open(c.config.Dns), &gorm.Config{})
c.Generator.UseDB(c.Db)
return c, nil
}
func NewGormGenPostgresqlClient(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(postgres.Open(c.config.Dns), &gorm.Config{})
c.Generator.UseDB(c.Db)
return c, nil
}