()
| 142 | } |
| 143 | |
| 144 | func ExampleDB_Model_insertOnConflictDoNothing() { |
| 145 | db := modelDB() |
| 146 | |
| 147 | book := &Book{ |
| 148 | ID: 100, |
| 149 | Title: "book 100", |
| 150 | } |
| 151 | |
| 152 | for i := 0; i < 2; i++ { |
| 153 | res, err := db.Model(book).OnConflict("DO NOTHING").Insert() |
| 154 | if err != nil { |
| 155 | panic(err) |
| 156 | } |
| 157 | if res.RowsAffected() > 0 { |
| 158 | fmt.Println("created") |
| 159 | } else { |
| 160 | fmt.Println("did nothing") |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | _, err := db.Model(book).WherePK().Delete() |
| 165 | if err != nil { |
| 166 | panic(err) |
| 167 | } |
| 168 | |
| 169 | // Output: created |
| 170 | // did nothing |
| 171 | } |
| 172 | |
| 173 | func ExampleDB_Model_insertOnConflictDoUpdate() { |
| 174 | db := modelDB() |
nothing calls this directly
no test coverage detected
searching dependent graphs…