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

Function ExampleDB_Model_insert

example_model_test.go:76–95  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

74}
75
76func ExampleDB_Model_insert() {
77 db := modelDB()
78
79 book := &Book{
80 Title: "new book",
81 AuthorID: 1,
82 }
83
84 _, err := db.Model(book).Insert()
85 if err != nil {
86 panic(err)
87 }
88 fmt.Println(book)
89 // Output: Book<Id=4 Title="new book">
90
91 _, err = db.Model(book).WherePK().Delete()
92 if err != nil {
93 panic(err)
94 }
95}
96
97func ExampleDB_Model_bulkInsert() {
98 db := modelDB()

Callers

nothing calls this directly

Calls 5

modelDBFunction · 0.85
InsertMethod · 0.80
DeleteMethod · 0.80
WherePKMethod · 0.80
ModelMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…