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

Function ExampleDB_Model_bulkInsert

example_model_test.go:97–119  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

95}
96
97func ExampleDB_Model_bulkInsert() {
98 db := modelDB()
99
100 book1 := &Book{
101 Title: "new book 1",
102 }
103 book2 := &Book{
104 Title: "new book 2",
105 }
106 _, err := db.Model(book1, book2).Insert()
107 if err != nil {
108 panic(err)
109 }
110 fmt.Println(book1, book2)
111 // Output: Book<Id=4 Title="new book 1"> Book<Id=5 Title="new book 2">
112
113 for _, book := range []*Book{book1, book2} {
114 _, err := db.Model(book).WherePK().Delete()
115 if err != nil {
116 panic(err)
117 }
118 }
119}
120
121func ExampleDB_Model_bulkInsertSlice() {
122 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…