Skip to content

Commit

Permalink
feat: add gen.go
Browse files Browse the repository at this point in the history
feat: init gen.go
  • Loading branch information
tr1v3r committed Jan 16, 2024
1 parent e5208c4 commit 4f84925
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
21 changes: 21 additions & 0 deletions gen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package main

import (
"gorm.io/gen"
"gorm.io/gen/examples/dal"
)

func generate() {
g := gen.NewGenerator(gen.Config{
OutPath: "./dal/query",
Mode: gen.WithDefaultQuery, /*WithQueryInterface, WithoutContext*/

WithUnitTest: true,
})
g.UseDB(dal.DB)

g.ApplyBasic(Company{}, Language{}) // Associations
g.ApplyBasic(g.GenerateModel("user"), g.GenerateModelAs("account", "AccountInfo"))

g.Execute()
}
13 changes: 10 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ module gorm.io/playground
go 1.20

require (
gorm.io/driver/mysql v1.5.1
gorm.io/driver/mysql v1.5.2
gorm.io/driver/postgres v1.5.2
gorm.io/driver/sqlite v1.5.3
gorm.io/driver/sqlserver v1.5.1
gorm.io/gen v0.3.25
gorm.io/gorm v1.25.4
)

Expand All @@ -21,8 +22,14 @@ require (
github.com/jinzhu/now v1.1.5 // indirect
github.com/mattn/go-sqlite3 v1.14.17 // indirect
github.com/microsoft/go-mssqldb v1.5.0 // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/text v0.12.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/tools v0.15.0 // indirect
gorm.io/datatypes v1.1.1-0.20230130040222-c43177d3cf8c // indirect
gorm.io/hints v1.1.0 // indirect
gorm.io/plugin/dbresolver v1.5.0 // indirect
)

replace gorm.io/gorm => ./gorm

0 comments on commit 4f84925

Please sign in to comment.