Skip to content

Commit 4f84925

Browse files
committed
feat: add gen.go
feat: init gen.go
1 parent e5208c4 commit 4f84925

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

gen.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package main
2+
3+
import (
4+
"gorm.io/gen"
5+
"gorm.io/gen/examples/dal"
6+
)
7+
8+
func generate() {
9+
g := gen.NewGenerator(gen.Config{
10+
OutPath: "./dal/query",
11+
Mode: gen.WithDefaultQuery, /*WithQueryInterface, WithoutContext*/
12+
13+
WithUnitTest: true,
14+
})
15+
g.UseDB(dal.DB)
16+
17+
g.ApplyBasic(Company{}, Language{}) // Associations
18+
g.ApplyBasic(g.GenerateModel("user"), g.GenerateModelAs("account", "AccountInfo"))
19+
20+
g.Execute()
21+
}

go.mod

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ module gorm.io/playground
33
go 1.20
44

55
require (
6-
gorm.io/driver/mysql v1.5.1
6+
gorm.io/driver/mysql v1.5.2
77
gorm.io/driver/postgres v1.5.2
88
gorm.io/driver/sqlite v1.5.3
99
gorm.io/driver/sqlserver v1.5.1
10+
gorm.io/gen v0.3.25
1011
gorm.io/gorm v1.25.4
1112
)
1213

@@ -21,8 +22,14 @@ require (
2122
github.com/jinzhu/now v1.1.5 // indirect
2223
github.com/mattn/go-sqlite3 v1.14.17 // indirect
2324
github.com/microsoft/go-mssqldb v1.5.0 // indirect
24-
golang.org/x/crypto v0.12.0 // indirect
25-
golang.org/x/text v0.12.0 // indirect
25+
golang.org/x/crypto v0.14.0 // indirect
26+
golang.org/x/mod v0.14.0 // indirect
27+
golang.org/x/sys v0.14.0 // indirect
28+
golang.org/x/text v0.13.0 // indirect
29+
golang.org/x/tools v0.15.0 // indirect
30+
gorm.io/datatypes v1.1.1-0.20230130040222-c43177d3cf8c // indirect
31+
gorm.io/hints v1.1.0 // indirect
32+
gorm.io/plugin/dbresolver v1.5.0 // indirect
2633
)
2734

2835
replace gorm.io/gorm => ./gorm

0 commit comments

Comments
 (0)