Skip to content

Commit a908abb

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 33d203d + a844a9a commit a908abb

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

README.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ go get github.com/gorm-plus/gorm-plus
99

1010
```go
1111

12+
1213
func init() {
1314
dsn := "root:root-abcd-1234@tcp(127.0.0.1:3306)/test?charset=utf8mb4&parseTime=True&loc=Local"
1415
var err error
@@ -27,14 +28,14 @@ type Test1 struct {
2728

2829
func TestSave(t *testing.T) {
2930
test1 := Test1{Code: "D1", Price: 100}
30-
resultDb := mapper.Insert(&test1)
31+
resultDb := gormplus.Insert(&test1)
3132
fmt.Println(resultDb)
3233
fmt.Println(test1)
3334
}
3435

3536
func TestSaveMigrate(t *testing.T) {
3637
test1 := Test1{Code: "D2", Price: 100}
37-
resultDb, err := mapper.InsertMigrate(&test1)
38+
resultDb, err := gormplus.InsertMigrate(&test1)
3839
if err != nil {
3940
fmt.Println(err)
4041
}
@@ -45,7 +46,7 @@ func TestSaveMigrate(t *testing.T) {
4546
func TestBatchSave(t *testing.T) {
4647
test1 := Test1{Code: "D3", Price: 100}
4748
test2 := Test1{Code: "D4", Price: 100}
48-
resultDb := mapper.InsertBatch(&test1, &test2)
49+
resultDb := gormplus.InsertBatch(&test1, &test2)
4950
fmt.Println(resultDb)
5051
fmt.Println(test1)
5152
fmt.Println(test2)
@@ -54,7 +55,7 @@ func TestBatchSave(t *testing.T) {
5455
func TestSaveBatchMigrate(t *testing.T) {
5556
test1 := Test1{Code: "D5", Price: 100}
5657
test2 := Test1{Code: "D6", Price: 100}
57-
resultDb, err := mapper.InsertBatchMigrate(&test1, &test2)
58+
resultDb, err := gormplus.InsertBatchMigrate(&test1, &test2)
5859
if err != nil {
5960
fmt.Println(err)
6061
}
@@ -64,68 +65,68 @@ func TestSaveBatchMigrate(t *testing.T) {
6465
}
6566

6667
func TestDeleteById(t *testing.T) {
67-
resultDb := mapper.DeleteById[Test1](1)
68+
resultDb := gormplus.DeleteById[Test1](1)
6869
fmt.Println(resultDb)
6970
}
7071

7172
func TestDeleteByIds(t *testing.T) {
72-
resultDb := mapper.DeleteByIds[Test1](4, 5)
73+
resultDb := gormplus.DeleteByIds[Test1](4, 5)
7374
fmt.Println(resultDb)
7475
}
7576

7677
func TestDelete(t *testing.T) {
77-
q := mapper.Query[Test1]{}
78+
q := gormplus.Query[Test1]{}
7879
q.Eq("code", "D1").Eq("price", 100)
79-
resultDb := mapper.Delete(&q)
80+
resultDb := gormplus.Delete(&q)
8081
fmt.Println(resultDb)
8182
}
8283

8384
func TestUpdateById(t *testing.T) {
8485
test1 := Test1{Code: "777"}
85-
resultDb := mapper.UpdateById(6, &test1)
86+
resultDb := gormplus.UpdateById(6, &test1)
8687
fmt.Println(resultDb)
8788
}
8889

8990
func TestUpdate(t *testing.T) {
90-
q := mapper.Query[Test1]{}
91+
q := gormplus.Query[Test1]{}
9192
q.Eq("code", "D42").Eq("price", 100)
9293
test1 := Test1{Code: "888"}
93-
resultDb := mapper.Update(&q, &test1)
94+
resultDb := gormplus.Update(&q, &test1)
9495
fmt.Println(resultDb)
9596
}
9697

9798
func TestSelectById(t *testing.T) {
98-
db, result := mapper.SelectById[Test1](1)
99+
db, result := gormplus.SelectById[Test1](1)
99100
fmt.Println(db)
100101
fmt.Println(result)
101102
}
102103

103104
func TestSelectByIds(t *testing.T) {
104-
db, result := mapper.SelectByIds[Test1](1, 2)
105+
db, result := gormplus.SelectByIds[Test1](1, 2)
105106
fmt.Println(db)
106107
fmt.Println(result)
107108
}
108109

109110
func TestSelectOne(t *testing.T) {
110-
q := mapper.Query[Test1]{}
111+
q := gormplus.Query[Test1]{}
111112
q.Eq("code", "D42").Eq("price", 100)
112-
db, result := mapper.SelectOne(&q)
113+
db, result := gormplus.SelectOne(&q)
113114
fmt.Println(db)
114115
fmt.Println(result)
115116
}
116117

117118
func TestSelectList(t *testing.T) {
118-
q := mapper.Query[Test1]{}
119+
q := gormplus.Query[Test1]{}
119120
q.Eq("price", 100)
120-
db, result := mapper.SelectList(&q)
121+
db, result := gormplus.SelectList(&q)
121122
fmt.Println(db.RowsAffected)
122123
fmt.Println(result)
123124
}
124125

125126
func TestSelectCount(t *testing.T) {
126-
q := mapper.Query[Test1]{}
127+
q := gormplus.Query[Test1]{}
127128
q.Eq("price", 100)
128-
db, count := mapper.SelectCount(&q)
129+
db, count := gormplus.SelectCount(&q)
129130
fmt.Println(db)
130131
fmt.Println(count)
131132
}

0 commit comments

Comments
 (0)