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

Function ExampleDB_Model_updateSetValues

example_model_test.go:877–892  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

875}
876
877func ExampleDB_Model_updateSetValues() {
878 db := modelDB()
879
880 var book Book
881 _, err := db.Model(&book).
882 Set("title = concat(?, title, ?)", "prefix ", " suffix").
883 Where("id = ?", 1).
884 Returning("*").
885 Update()
886 if err != nil {
887 panic(err)
888 }
889
890 fmt.Println(book)
891 // Output: Book<Id=1 Title="prefix book 1 suffix">
892}
893
894func ExampleDB_Model_bulkUpdate() {
895 db := modelDB()

Callers

nothing calls this directly

Calls 6

modelDBFunction · 0.85
UpdateMethod · 0.80
ReturningMethod · 0.80
WhereMethod · 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…