forked from mirror/gorm
Yay, users inserted
This commit is contained in:
parent
c26e10813d
commit
0b1facc513
2
orm.go
2
orm.go
|
@ -26,7 +26,7 @@ type Orm struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Orm) setModel(model interface{}) (err error) {
|
func (s *Orm) setModel(model interface{}) (err error) {
|
||||||
s.TableName = "user"
|
s.TableName = "users"
|
||||||
s.PrimaryKey = "id"
|
s.PrimaryKey = "id"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package gorm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
|
||||||
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
@ -19,10 +18,7 @@ func getDB() DB {
|
||||||
func TestSaveAndFirst(t *testing.T) {
|
func TestSaveAndFirst(t *testing.T) {
|
||||||
db := getDB()
|
db := getDB()
|
||||||
u := &User{Name: "jinzhu"}
|
u := &User{Name: "jinzhu"}
|
||||||
fmt.Println("*******")
|
db.Save(u)
|
||||||
fmt.Println(db.Save(u).Sql)
|
|
||||||
fmt.Println(db.Save(u).Error)
|
|
||||||
fmt.Println(time.Now().String())
|
|
||||||
|
|
||||||
user := &User{}
|
user := &User{}
|
||||||
db.First(&user)
|
db.First(&user)
|
||||||
|
|
Loading…
Reference in New Issue