Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterEnd ¶
FilterEnd is used with ListShifts to filter Shift results that have end times that fall on or after the specified filtered time. If end is specified as a time.Time zero value, it is ignored.
func FilterStart ¶
FilterStart is used with ListShifts to filter Shift results that have start times that fall on or before the specified filtered time. If start is specified as a time.Time zero value, it is ignored.
func FilterUserID ¶
FilterUserID is used with ListShifts to filter the query to return results matching the specific User.ID If uid is not an empty string, results will be filtered by that User.ID
Types ¶
type Shift ¶
type Shift struct { ID string `gorm:"primaryKey" json:"id"` Start time.Time `gorm:"not null" json:"start"` End time.Time `gorm:"not null" json:"end"` UserID string `gorm:"not null" json:"user_id"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
Shift struct represents a timespan of a work shift object with a Unique ID, Start and End times, and a UserID which the shift belongs to.
func FindShiftByID ¶
FindShiftByID attempts to return a row from the Shifts table with the matching ID
func ListShifts ¶
func ListShifts(db *gorm.DB, opts ...ShiftFilterOption) ([]*Shift, error)
ListShifts attempts to return rows from the Shifts table with the specified limits and filters ordered by start time Provide ShiftFilterOption parameters to modify the query with additional filters.
func (*Shift) BeforeCreate ¶
BeforeCreate hooks GORM and prepares a new object for creation
func (*Shift) BeforeSave ¶
BeforeSave hooks GORM to run necessary checks before saving the object
type ShiftFilterOption ¶
type User ¶
type User struct { ID string `gorm:"primaryKey" json:"id"` Name string `gorm:"size:30;not null;unique'" json:"name"` //login name Password string `gorm:"size:100;not null" json:"password,omitempty"` //bcrypt hash Role string `gorm:"size:10;not null" json:"role"` //user role: user, admin CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
User struct represents a user with a unique ID, Name, Password, and Role
func FindUserByID ¶
FindUserByID attempts to return a row from the Users table with the matching User.ID
func FindUserByName ¶
FindUserByName attempts to return a row from the Users table with the matching User.Name
func ListUsers ¶
ListUsers attempts to return rows from the Users table with the specified limit If limit specified is less than or equal to 0, result will not be limited.
func (*User) AfterDelete ¶
AfterDelete hooks GORM to remove the associated Shift rows for ths user when it is deleted
func (*User) Prepare ¶
Prepare prepares a new object for update by escaping the name field and hashing the password field before it is written