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

Function ExampleDB_Model_updateSomeColumns2

example_model_test.go:860–875  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

858}
859
860func ExampleDB_Model_updateSomeColumns2() {
861 db := modelDB()
862
863 book := Book{
864 ID: 1,
865 Title: "updated book 1",
866 AuthorID: 2, // this column will not be updated
867 }
868 _, err := db.Model(&book).Set("title = ?title").WherePK().Returning("*").Update()
869 if err != nil {
870 panic(err)
871 }
872
873 fmt.Println(book, book.AuthorID)
874 // Output: Book<Id=1 Title="updated book 1"> 1
875}
876
877func ExampleDB_Model_updateSetValues() {
878 db := modelDB()

Callers

nothing calls this directly

Calls 6

modelDBFunction · 0.85
UpdateMethod · 0.80
ReturningMethod · 0.80
WherePKMethod · 0.80
SetMethod · 0.80
ModelMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…