1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| //数据插入 user := User{Id: 0001, Name: "小蜗", Age: 20, Salt: " ", Passwd: "root"} n, _ := engine.Insert(&user) if n >= 1 { fmt.Println("插入成功") } //切片插入 var users []User users = append(users, User{Id: 0002, Name: "小蜗", Age: 20, Salt: " ", Passwd: "root"}) users = append(users, User{Id: 0003, Name: "小蜗", Age: 20, Salt: " ", Passwd: "root"}) n, _ := engine.Insert(&users) if n >= 1 { fmt.Println("切片插入成功") } //update delete user := User{Name: "小天才"} n, _ := engine.ID(0001).Update(&user) if n >= 1 { fmt.Println("update 成功") }
|