Skip to content

Commit 3250123

Browse files
committed
Test the embedding model located in the current path
1 parent 1a7be25 commit 3250123

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

examples/models/user.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ import (
44
"database/sql"
55
"time"
66

7+
"gorm.io/cli/gorm/genconfig"
78
"gorm.io/gorm"
89
)
910

11+
var _ = genconfig.Config{
12+
ExcludeStructs: []any{BaseModel{}},
13+
}
14+
1015
// User has one `Account` (has one), many `Pets` (has many) and `Toys` (has many - polymorphic)
1116
// He works in a Company (belongs to), he has a Manager (belongs to - single-table), and also managed a Team (has many - single-table)
1217
// He speaks many languages (many to many) and has many friends (many to many - single-table)
@@ -49,7 +54,7 @@ type Pet struct {
4954
}
5055

5156
type Toy struct {
52-
gorm.Model
57+
BaseModel
5358
Name string
5459
OwnerID uint
5560
OwnerType string
@@ -69,3 +74,10 @@ type CreditCard struct {
6974
*gorm.Model
7075
Number string
7176
}
77+
78+
type BaseModel struct {
79+
ID uint `gorm:"primarykey"`
80+
CreatedAt time.Time
81+
UpdatedAt time.Time
82+
DeletedAt gorm.DeletedAt `gorm:"index"`
83+
}

examples/typed/models/user.go

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)