Skip to content

Commit e5ba638

Browse files
committed
Deleting data di database
1 parent 2cbf69a commit e5ba638

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,10 @@ To bind a request body into a type, use model binding. We currently support bind
5555
Gin uses https://github.com/go-playground/validator for validation. Check the full docs on tags usage https://godoc.org/github.com/go-playground/validator#hdr-Baked_In_Validators_and_Tags.
5656

5757
Note that you need to set the corresponding binding tag on all fields you want to bind. For example, when binding from JSON, set json:"fieldname".
58+
59+
## GORM
60+
Database Connection
61+
The fantastic ORM library for Golang, aims to be developer friendly.
62+
63+
### Geting Started
64+
GORM Guides https://gorm.io

main.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,27 @@ func main() {
5555
fmt.Println("================================")
5656
}
5757

58+
err = db.Delete(&book).Error
59+
60+
if err != nil {
61+
fmt.Println("================================")
62+
fmt.Println("Error Deleting book record")
63+
fmt.Println("================================")
64+
}
65+
5866
// for _, b := range books {
5967

6068
// fmt.Println("title:", b.Title)
6169
// fmt.Println("book object", b)
6270
// }
6371

64-
book.Title = "Cari Pengalaman Perlu Pengalaman Juga"
65-
err = db.Save(&book).Error
66-
if err != nil {
67-
fmt.Println("================================")
68-
fmt.Println("Error Updating book record")
69-
fmt.Println("================================")
70-
}
72+
// book.Title = "Cari Pengalaman Perlu Pengalaman Juga"
73+
// err = db.Save(&book).Error
74+
// if err != nil {
75+
// fmt.Println("================================")
76+
// fmt.Println("Error Updating book record")
77+
// fmt.Println("================================")
78+
// }
7179

7280
router := gin.Default()
7381

0 commit comments

Comments
 (0)