()
| 204 | } |
| 205 | |
| 206 | func ExampleDB_Model_selectOrInsert() { |
| 207 | db := modelDB() |
| 208 | |
| 209 | author := Author{ |
| 210 | Name: "R. Scott Bakker", |
| 211 | } |
| 212 | created, err := db.Model(&author). |
| 213 | Column("id"). |
| 214 | Where("name = ?name"). |
| 215 | OnConflict("DO NOTHING"). // OnConflict is optional |
| 216 | Returning("id"). |
| 217 | SelectOrInsert() |
| 218 | if err != nil { |
| 219 | panic(err) |
| 220 | } |
| 221 | fmt.Println(created, author) |
| 222 | // Output: true Author<ID=2 Name="R. Scott Bakker"> |
| 223 | } |
| 224 | |
| 225 | func ExampleDB_Model_insertDynamicTableName() { |
| 226 | type NamelessModel struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…