Documentation
¶
Index ¶
- func Open(dialector gorm.Dialector) (*gorm.DB, error)
- type Repo
- type Session
- type User
- func (u *User) BeforeCreate(tx *gorm.DB) error
- func (u *User) BeforeSave(tx *gorm.DB) error
- func (u *User) Create(db *gorm.DB) error
- func (u *User) Find(db *gorm.DB, id interface{}) error
- func (u *User) FindByEmail(db *gorm.DB, email string) error
- func (u *User) FindByEmailOrUsername(db *gorm.DB, email, username string) error
- func (u *User) FindByUsername(db *gorm.DB, username string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Repo ¶
type Repo struct {
// UserID is the owner's ID.
UserID uint `gorm:"index:name_user_id,unique"`
// Name is the repository name.
Name string `gorm:"index:name_user_id,unique"`
// Description is the repository description.
Description string
// User is the owner of the repository.
User User
// CID is the content identifier of the repository.
CID string
gorm.Model
}
Repo contains repository info.
func (*Repo) BeforeSave ¶
BeforeSave validates fields before saving.
func (*Repo) FindByNameAndUserID ¶
type Session ¶
type Session struct {
// ID is the unique session ID.
ID string `gorm:"primaryKey"`
// UserID is the owner's ID.
UserID uint `gorm:"index"`
// User is the session user.
User User
// CreatedAt is the time the session was created.
CreatedAt time.Time
// UpdatedAt is the time the session was updated.
UpdatedAt time.Time
}
Session contains session details.
func (*Session) BeforeCreate ¶
BeforeCreate validates fields before creating.
type User ¶
type User struct {
// Username is an alias for the user.
Username string `gorm:"uniqueIndex"`
// Email is the account email address.
Email string `gorm:"uniqueIndex"`
// Password is the plain text password.
Password string `gorm:"-"`
// PasswordHash contains the hased password.
PasswordHash []byte
gorm.Model
}
User contains account details.
func (*User) BeforeCreate ¶
BeforeCreate validates fields before creating.
func (*User) BeforeSave ¶
BeforeSave validates fields before saving.
func (*User) FindByEmailOrUsername ¶
Click to show internal directories.
Click to hide internal directories.