2024-02-11 10:56:21 +00:00
|
|
|
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{
|
2024-02-11 11:57:57 +00:00
|
|
|
OutPath: "internal/models/query",
|
2024-02-11 10:56:21 +00:00
|
|
|
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()
|
|
|
|
}
|