Documentation ¶
Index ¶
- type BodyError
- type FieldError
- type Group
- func (g *Group) Create() error
- func (g *Group) InitDB() error
- func (g *Group) IsFull() bool
- func (g *Group) IsMember(uid int64) bool
- func (g *Group) IsOpen() bool
- func (g *Group) IsOwner(uid int64) bool
- func (g *Group) IsPrivate() bool
- func (g *Group) List() ([]Group, error)
- func (g *Group) Migrate() error
- func (g *Group) RemoveMember(u User) error
- func (g *Group) Retrieve() error
- func (g *Group) RetrieveWithPassword() error
- func (g *Group) Update() error
- func (g *Group) ValidateForCreate() error
- func (g *Group) ValidatePassword(pw string) error
- type TokenResponse
- type User
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BodyError ¶
type BodyError struct { Message string `json:"message,omitempty"` FieldErrors []FieldError `json:"field_errors,omitempty"` }
type FieldError ¶
type Group ¶
type Group struct { ID int64 `json:"id,omitempty" gorm:"primaryKey"` Title string `json:"title,omitempty" gorm:"not null"` Description string `json:"description,omitempty"` Status int16 `json:"status" gorm:"default:0"` Password string `json:"password,omitempty"` MaxSize int16 `json:"max_size,omitempty" gorm:"default:5"` CreatedAt time.Time `json:"created_at,omitempty" gorm:"autoCreateTime"` OwnerID int64 `json:"owner_id" gorm:"not null"` Members []User `json:"members" gorm:"many2many:joined_groups"` DB *gorm.DB `json:"-" gorm:"-"` }
func (*Group) RemoveMember ¶
RemoveMember removes a user from the group.
func (*Group) Retrieve ¶
Retrieve retrieves the group details from the database given its database ID.
func (*Group) RetrieveWithPassword ¶
RetrieveWithPassword returns the group details from the database given its ID.
The returned Group includes the password value.
func (*Group) ValidateForCreate ¶
ValidateForCreate checks if the group is a valid new entry.
func (*Group) ValidatePassword ¶
ValidatePassword validates the group password
type TokenResponse ¶
type User ¶
type User struct { ID int64 `json:"id" gorm:"primaryKey"` Username string `json:"username" gorm:"unique"` Password string `json:"password,omitempty"` CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"` MyGroups []Group `json:"-" gorm:"foreignKey:OwnerID"` JoinedGroups []Group `json:"-" gorm:"many2many:joined_groups"` DB *gorm.DB `json:"-" gorm:"-"` }
func (*User) BeforeCreate ¶
BeforeCreate hashes the password of the user before adding it to the DB.
func (*User) RetrieveByUsername ¶
RetrieveUserByUsername retrieves a user details given its username.
func (*User) ValidateForSignUp ¶
ValidateForSignUp checks if the user struct is valid for sign up.
type ValidationError ¶
type ValidationError struct { Message string Errors []FieldError }
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
Click to show internal directories.
Click to hide internal directories.