web 服务框架
This commit is contained in:
30
cmd/gen/main.go
Normal file
30
cmd/gen/main.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"gorm.io/driver/postgres"
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/schema"
|
||||
)
|
||||
|
||||
func main() {
|
||||
g := gen.NewGenerator(gen.Config{
|
||||
OutPath: "web/queries",
|
||||
ModelPkgPath: "models",
|
||||
Mode: gen.WithDefaultQuery | gen.WithoutContext,
|
||||
})
|
||||
|
||||
db, _ := gorm.Open(
|
||||
postgres.Open("host=localhost user=test password=test dbname=app port=5432 sslmode=disable TimeZone=Asia/Shanghai"),
|
||||
&gorm.Config{
|
||||
NamingStrategy: schema.NamingStrategy{
|
||||
SingularTable: true,
|
||||
},
|
||||
},
|
||||
)
|
||||
g.UseDB(db)
|
||||
|
||||
models := g.GenerateAllTable()
|
||||
g.ApplyBasic(models...)
|
||||
g.Execute()
|
||||
}
|
||||
Reference in New Issue
Block a user