Documentation
¶
Index ¶
- type City
- type Model
- type User
- func (user User) Delete(db *gorm.DB, id int) error
- func (User) FindAll(db *gorm.DB) ([]User, error)
- func (user User) FirstByCityID(db *gorm.DB, id int) (*User, error)
- func (user User) FirstByID(db *gorm.DB, id int) (*User, error)
- func (user User) FirstByIDAndUsername(db *gorm.DB, id int, username string, too ...bool) (*User, error)
- func (user User) Save(db *gorm.DB) (*User, error)
- func (user User) Update(db *gorm.DB, id int) (*User, error)
- func (user User) UpdateByIDandPassword(db *gorm.DB, id int, password string) (err error)
- type UserCity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Model ¶
type Model struct {
ID uint `gorm:"primarykey"`
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
gorm.Model
type User ¶
type User struct {
Model
// database: just `username` varchar 15
Username string `gorm:"unique;not null;type:varchar(15)" form:"username"`
Email string `gorm:"unique;not null" form:"email"`
Password string `gorm:"not null" form:"password"`
Name string `gorm:"not null" form:"name"`
City uint `form:"city"`
Photo string `form:"photo"`
}
User: struct
func (User) FirstByCityID ¶
User: FirstByCityID
func (User) FirstByIDAndUsername ¶
func (user User) FirstByIDAndUsername(db *gorm.DB, id int, username string, too ...bool) (*User, error)
User: FirstByIDAndUsername
example: user, err := models.User{}.FirstByIDAndUsername(controllers.DB, 1, "ockibagusp")
or,
user, err := models.User{}.FirstByIDAndUsername(controllers.DB, 1, "ockibagusp", true)
Click to show internal directories.
Click to hide internal directories.