File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,9 @@ func AddProject(c *gin.Context) {
30
30
return
31
31
}
32
32
db := dbconfig .GetDb ()
33
+ instance , _ := db .DB ()
34
+ defer instance .Close ()
35
+
33
36
var project models.Project
34
37
id := uuid .New ()
35
38
project .Id = id .String ()
@@ -55,6 +58,8 @@ func AddProject(c *gin.Context) {
55
58
56
59
func GetAllProjects (c * gin.Context ) {
57
60
db := dbconfig .GetDb ()
61
+ instance , _ := db .DB ()
62
+ defer instance .Close ()
58
63
var projects []models.Project
59
64
err := db .Model (& models.Project {}).Find (& projects ).Error
60
65
if err != nil {
@@ -69,6 +74,9 @@ func GetAllProjects(c *gin.Context) {
69
74
70
75
func getProjectById (c * gin.Context ) {
71
76
db := dbconfig .GetDb ()
77
+ instance , _ := db .DB ()
78
+ defer instance .Close ()
79
+
72
80
id := c .Query ("id" )
73
81
74
82
var project models.Project
Original file line number Diff line number Diff line change @@ -47,7 +47,8 @@ func GetDb() *gorm.DB {
47
47
48
48
func Init () error {
49
49
db := GetDb ()
50
-
50
+ instance , _ := db .DB ()
51
+ defer instance .Close ()
51
52
err := db .AutoMigrate (& models.Project {})
52
53
if err != nil {
53
54
log .Fatal (err )
You can’t perform that action at this time.
0 commit comments