示例#1
0
文件: user.go 项目: awakia/go_sokushu
// Constructor
func NewUser(name string, age int) *User {
	user := &User{
		Name: name,
		Age:  age,
	}
	db.Get().Create(user)
	return user
}
示例#2
0
文件: user.go 项目: awakia/go_sokushu
func AllUsers() []*User {
	var users []*User
	db.Get().Find(&users)
	return users
}
示例#3
0
文件: user.go 项目: awakia/go_sokushu
func GetUser(id int) *User {
	var user *User
	db.Get().Where("id = ?", id).First(user)
	return user
}