mirror of
https://github.com/mentos1386/zdravko.git
synced 2024-11-22 07:43:33 +00:00
28 lines
726 B
Go
28 lines
726 B
Go
package main
|
|
|
|
import (
|
|
"code.tjo.space/mentos1386/zdravko/internal"
|
|
"code.tjo.space/mentos1386/zdravko/internal/models"
|
|
"gorm.io/gen"
|
|
)
|
|
|
|
func main() {
|
|
// Initialize the generator with configuration
|
|
g := gen.NewGenerator(gen.Config{
|
|
OutPath: "internal/models/query",
|
|
Mode: gen.WithDefaultQuery | gen.WithQueryInterface,
|
|
FieldNullable: true,
|
|
})
|
|
|
|
db, _ := internal.ConnectToDatabase()
|
|
|
|
// Use the above `*gorm.DB` instance to initialize the generator,
|
|
// which is required to generate structs from db when using `GenerateModel/GenerateModelAs`
|
|
g.UseDB(db)
|
|
|
|
// Generate default DAO interface for those specified structs
|
|
g.ApplyBasic(models.Healthcheck{})
|
|
|
|
// Execute the generator
|
|
g.Execute()
|
|
}
|