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