Documentation
¶
Index ¶
- Constants
- Variables
- func ValidateCursors(v *validator.Validator, c Cursor)
- func ValidateEmail(v *validator.Validator, email string)
- func ValidateFilters(v *validator.Validator, f Filters)
- func ValidateItem(v *validator.Validator, item *Item)
- func ValidatePasswordPlaintext(v *validator.Validator, password string)
- func ValidateTokenPlaintext(v *validator.Validator, tokenPlaintext string)
- func ValidateUser(v *validator.Validator, user *User)
- type Cursor
- type Filters
- type Item
- type ItemModel
- type Metadata
- type Models
- type Token
- type TokenModel
- type User
- type UserModel
Constants ¶
View Source
const ( ScopeActivation = "activation" ScopeAuthentication = "authentication" )
View Source
const ( USER_ROLE = "user" ADMIN_ROLE = "admin" ANALYTIC_ROLE = "analytic" ITEM_CREATOR_ROLE = "item_creator" )
Variables ¶
View Source
var ( ErrRecordNotFound = errors.New("record not found") ErrEditConflict = errors.New("edit conflict") )
View Source
var AnonymousUser = &User{}
View Source
var (
ErrDuplicateEmail = errors.New("duplicate email")
)
Functions ¶
func ValidateCursors ¶
func ValidateEmail ¶
func ValidateFilters ¶
func ValidateItem ¶
func ValidateTokenPlaintext ¶
func ValidateUser ¶
Types ¶
type Cursor ¶
type Cursor struct { LastSortVal interface{} `json:"last_sort_val,omitempty"` LastID int64 `json:"last_id,omitempty"` }
type Item ¶
type Item struct { ID int64 `json:"id"` CreatedAt time.Time `json:"-"` Name string `json:"name"` Category string `json:"category"` CreatedBy int64 `json:"created_by"` Quantity int `json:"quantity"` Pcode string `json:"pcode"` ImageURL string `json:"image_url,omitempty"` Version int32 `json:"version"` }
type Models ¶
type Models struct { Items ItemModel Users UserModel Tokens TokenModel }
type TokenModel ¶
func (TokenModel) DeleteAllForUser ¶
func (m TokenModel) DeleteAllForUser(scope string, userID int64) error
DeleteAllForUser() deletes all tokens for a specific user and scope.
func (TokenModel) Insert ¶
func (m TokenModel) Insert(token *Token) error
Insert() adds the data for a specific token to the tokens table.
type User ¶
type User struct { ID int64 `json:"id"` CreatedAt time.Time `json:"created_at"` FirstName string `json:"first_name"` LastName string `json:"last_name"` Email string `json:"email"` Pcode string `json:"pcode"` Phone string `json:"phone,omitempty"` ImageURL string `json:"image_url,omitempty"` Password password `json:"-"` Activated bool `json:"activated"` Role string `json:"-"` Version int `json:"-"` }
func (*User) IsAnonymous ¶
type UserModel ¶
func (UserModel) GetForToken ¶
Click to show internal directories.
Click to hide internal directories.