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

Function ExampleDB_Model_updateNotZero

example_model_test.go:777–797  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

775}
776
777func ExampleDB_Model_updateNotZero() {
778 db := modelDB()
779
780 book := &Book{
781 ID: 1,
782 Title: "updated book 1",
783 }
784 _, err := db.Model(book).WherePK().UpdateNotZero()
785 if err != nil {
786 panic(err)
787 }
788
789 book = new(Book)
790 err = db.Model(book).Where("id = ?", 1).Select()
791 if err != nil {
792 panic(err)
793 }
794
795 fmt.Println(book)
796 // Output: Book<Id=1 Title="updated book 1">
797}
798
799func ExampleDB_Model_updateUseZeroBool() {
800 type Event struct {

Callers

nothing calls this directly

Calls 6

modelDBFunction · 0.85
UpdateNotZeroMethod · 0.80
WherePKMethod · 0.80
WhereMethod · 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…