File tree Expand file tree Collapse file tree 1 file changed +28
-3
lines changed Expand file tree Collapse file tree 1 file changed +28
-3
lines changed Original file line number Diff line number Diff line change 1
- # repoImpl
1
+ # repoimpl
2
2
Repositories, migrations and tests with model
3
3
4
4
@@ -10,21 +10,46 @@ The function writes table queries, repositories and tests for each model in the
10
10
go get github.com/realtemirov/repoimpl
11
11
```
12
12
13
- ## Migrations
13
+ ## Repository
14
14
```
15
15
type User struct {
16
16
Username string
17
17
Password string
18
18
}
19
19
20
- err := repoImpl.NewDBTable (User{})
20
+ err := repoimpl.NewRepository (User{})
21
21
if err != nil {
22
22
panic(err)
23
23
}
24
24
```
25
+ Repository implement CRUD to * postgres* database with sql package and creates ** interface storage**
25
26
27
+ ```
28
+ go run main.go
29
+ ```
30
+ ├─ repository \
31
+ &emsp ;&emsp ; ─ postgres \
32
+ &emsp ;&emsp ;&emsp ; ─ user.go - CRUD methods \
33
+ &emsp ;&emsp ; ─ storage.go - CRUD interfaces
26
34
35
+ ## Migrations
36
+ ```
37
+ type User struct {
38
+ Username string
39
+ Password string
40
+ }
41
+
42
+ err := repoimpl.NewMigration(User{})
43
+ if err != nil {
44
+ panic(err)
45
+ }
46
+ ```
27
47
Creates ** migration_user.sql** in the ** migrations** folder
48
+
49
+ ```
50
+ go run main.go
51
+ ```
52
+
28
53
```
29
54
CREATE TABLE IF NOT EXITS "users" (
30
55
"username" TEXT,
You can’t perform that action at this time.
0 commit comments