Apply .gitignore rules
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package connection
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
type testDal struct{}
|
||||
|
||||
func (t testDal) TableName() string {
|
||||
return "test"
|
||||
}
|
||||
|
||||
var TestDal = testDal{}
|
||||
|
||||
type User struct {
|
||||
ID uint `gorm:"primary_key"`
|
||||
Name string `gorm:"column:name"`
|
||||
Age int `gorm:"column:age"`
|
||||
Birthday time.Time `gorm:"column:birthday"`
|
||||
}
|
||||
|
||||
func TestExecute(t *testing.T) {
|
||||
user := User{Name: "Jinzhu", Age: 18, Birthday: time.Now()}
|
||||
|
||||
result := adminDB.Create(&user) // 通过数据的指针来创建
|
||||
|
||||
_ = user.ID // 返回插入数据的主键
|
||||
_ = result.Error // 返回 error
|
||||
_ = result.RowsAffected // 返回插入记录的条数
|
||||
}
|
||||
Reference in New Issue
Block a user