MCPcopy Create free account
hub / github.com/go-pg/pg / ExampleDB_Model_update

Function ExampleDB_Model_update

example_model_test.go:753–775  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

751}
752
753func ExampleDB_Model_update() {
754 db := modelDB()
755
756 book := &Book{ID: 1}
757 err := db.Model(book).WherePK().Select()
758 if err != nil {
759 panic(err)
760 }
761
762 book.Title = "updated book 1"
763 _, err = db.Model(book).WherePK().Update()
764 if err != nil {
765 panic(err)
766 }
767
768 err = db.Model(book).WherePK().Select()
769 if err != nil {
770 panic(err)
771 }
772
773 fmt.Println(book)
774 // Output: Book<Id=1 Title="updated book 1">
775}
776
777func ExampleDB_Model_updateNotZero() {
778 db := modelDB()

Callers

nothing calls this directly

Calls 5

modelDBFunction · 0.85
WherePKMethod · 0.80
UpdateMethod · 0.80
ModelMethod · 0.65
SelectMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…